Skip to content

Commit

Permalink
runonce: correct ~/Desktop if it is a file
Browse files Browse the repository at this point in the history
pi-apps could incorrectly create `~/Desktop` as a file if the `~/Desktop/` folder did not exist. correct this if observed
  • Loading branch information
theofficialgman committed Aug 3, 2023
1 parent 887715f commit a9a3669
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions etc/runonce-entries
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,32 @@ if ! command -v runonce >/dev/null ;then
source "${DIRECTORY}/api"
fi

#add ~/Desktop /opt /usr/local/bin and /usr/local/share/applications if not present
runonce <<"EOF"
if [ -f "$HOME/Desktop" ]; then
rm -f "$HOME/Desktop"
mkdir -p "$HOME/Desktop"
elif [ ! -d "$HOME/Desktop" ]; then
mkdir -p "$HOME/Desktop"
fi
if [ ! -d /opt ]; then
sudo_popup mkdir /opt
fi
if [ ! -d /usr/local/bin ]; then
sudo_popup mkdir -p /usr/local/bin
fi
if [ ! -d /usr/local/share/applications ]; then
sudo_popup mkdir -p /usr/local/share/applications
fi
#Pi-Apps tries to avoid unnecessary reboots at all cost. desktop launchers can be installed to /usr/local/share/applications, which is often not searched by default if /usr/local/share did not exist on boot.
#This path is added to $XDG_DATA_DIRS on the next reboot, but we don't want to wait for that!
#If XDG_DATA_DIRS is missing /usr/local/share, then bind-mount /usr/local/share/applications to /usr/share/applications
if [[ "$XDG_DATA_DIRS" != */usr/local/share* ]] && [ -z "$(ls /usr/share/applications/usr-local-temporary)" ];then
sudo_popup mkdir -p /usr/share/applications/usr-local-temporary
sudo_popup mount --bind /usr/local/share/applications /usr/share/applications/usr-local-temporary
fi
EOF

#generate settings
runonce <<"EOF"
if [ "$(ls "$DIRECTORY/data/settings" 2>/dev/null | wc -l)" -le 2 ];then
Expand Down Expand Up @@ -338,24 +364,4 @@ runonce <<"EOF"
fi
EOF

#add /opt /usr/local/bin and /usr/local/share/applications if not present
runonce <<"EOF"
if [ ! -d /opt ]; then
sudo_popup mkdir /opt
fi
if [ ! -d /usr/local/bin ]; then
sudo_popup mkdir -p /usr/local/bin
fi
if [ ! -d /usr/local/share/applications ]; then
sudo_popup mkdir -p /usr/local/share/applications
fi
#Pi-Apps tries to avoid unnecessary reboots at all cost. desktop launchers can be installed to /usr/local/share/applications, which is often not searched by default if /usr/local/share did not exist on boot.
#This path is added to $XDG_DATA_DIRS on the next reboot, but we don't want to wait for that!
#If XDG_DATA_DIRS is missing /usr/local/share, then bind-mount /usr/local/share/applications to /usr/share/applications
if [[ "$XDG_DATA_DIRS" != */usr/local/share* ]] && [ -z "$(ls /usr/share/applications/usr-local-temporary)" ];then
sudo_popup mkdir -p /usr/share/applications/usr-local-temporary
sudo_popup mount --bind /usr/local/share/applications /usr/share/applications/usr-local-temporary
fi
EOF

true

0 comments on commit a9a3669

Please sign in to comment.