Added stability

This commit is contained in:
Devin Dice 2022-08-10 10:30:15 -04:00
parent 063186e277
commit 88644b03e5

View file

@ -4,26 +4,28 @@ DIR=$(pwd)
export DISPLAY=:1.0
# Wait until dbus is listening.
until [[ $SUCCESS == "TRUE" ]]; do
SUCCESS="FALSE"
if test -f "$DBUS_FILE"; then SUCCESS="TRUE"; DBUS_ADDRESS=$(cat $DBUS_FILE); fi
echo "Wait for dbus to start."
until PID=$(pgrep xfce4-session); do
echo "Rechecking dbus"
sleep 1
done
done
# Export DBUS Variable
echo "DBUS Address: $DBUS_ADDRESS"
export DBUS_SESSION_BUS_ADDRESS="unix:abstract=$DBUS_ADDRESS"
echo "DBUS PID: $PID"
sleep 5
# Loop and check if its time to update the background
while true; do
PID=$(pgrep xfce4-session)
DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ | cut -d= -f2- | tr -d '\0')
export DBUS_SESSION_BUS_ADDRESS
FILE_COUNT=$(ls *.jpg | wc -l)
IMAGE_NUMBER=$(bc -l <<< "x=( $(date +%H) / ( 24 / $FILE_COUNT )); scale=0; x/1+1")
FILE=$(ls -1 *.jpg | sed "${IMAGE_NUMBER}q;d")
FILE=$DIR/$(ls -1 *.jpg | sed "${IMAGE_NUMBER}q;d")
OLD_FILE=$(xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorscreen/workspace0/last-image)
if [[ $FILE != $OLD_FILE ]]; then
echo "Setting new background to $FILE"
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorscreen/workspace0/last-image -n -t string -s $DIR/$FILE
OLD_FILE=$FILE
echo "Changing background from $OLD_FILE to $FILE"
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorscreen/workspace0/last-image -n -t string -s $FILE
OLD_FILEx=$FILE
fi
sleep 60
done