wmstartup: Polish up, add waiting code

Conky was getting stuck behind xfdesktop. This fixes that
This commit is contained in:
Salt 2018-07-31 15:35:18 -05:00
parent b97c40d41c
commit 260594af01

View File

@ -45,31 +45,38 @@ xset s off
xrdbupdate
## SERVICES AND DAEMONS
# Kill everything
printf "[INFO] Killing existing daemons\n"
services="sxhkd polybar conky dunst compton"
services="xfdesktop polybar compton conky sxhkd dunst"
for service in $services; do
printf " [INFO] Killing $service\n"
killall $service
done
# Wait for them to die
for service in $services; do
while pgrep $service; do
while pgrep $service > /dev/null 2>&1; do
printf " [INFO] Waiting for $service to die\n"
sleep 0.5
done
done
# Wallpaper management
# Note that this MUST happen before the compositor starts, otherwise xsetroot
# will not apply properly
wpm=feh
if which xfdesktop > /dev/null 2>&1; then
printf " [INFO] Starting xfdesktop\n"
xfdesktop&
wpm=xfdesktop
xfdesktop --disable-wm-check&
elif which feh > /dev/null 2>&1; then
printf " [INFO] Setting wallpaper with feh\n"
printf " [WARN] This solution may cause problems on multi-monitor systems\n"
feh --randomize --bg-fill ~/Pictures/Wallpapers/.active &
elif which xsetroot > /dev/null 2>&1; then
printf " [INFO] Setting root window color\n"
wpm=xsetroot
xsetroot -solid "#282828"
else
wpm=none
printf " [WARN] Could not find any wallpaper manager\n"
fi
# Don't start the compositor in a VM
@ -89,7 +96,27 @@ else
fi
# Start these all the time regardless of platform
printf "[INFO] Starting platform-independent tasks\n"
conky&
printf " [INFO] Starting dunst\n"
dunst&
printf " [INFO] Starting conky\n"
if [[ $wpm == "xfdesktop" ]]; then
printf " [INFO] Waiting for xfdesktop to initialize\n"
if which xdotool > /dev/null 2>&1; then
i=0
until xdotool search --class "xfdesktop"; do
i=$(expr $i + 1)
if [[ $i -ge 10 ]]; then
printf " [WARN] Grew too impatient!\n"
break
fi
sleep 1
done
unset i
else
printf " [WARN] Could not find xdotool!\n"
fi
printf " [INFO] Finished waiting\n"
fi
conky&
printf "[INFO] Finished initialization\n"