Added stability
This commit is contained in:
parent
063186e277
commit
88644b03e5
|
|
@ -4,26 +4,28 @@ DIR=$(pwd)
|
||||||
|
|
||||||
export DISPLAY=:1.0
|
export DISPLAY=:1.0
|
||||||
|
|
||||||
# Wait until dbus is listening.
|
echo "Wait for dbus to start."
|
||||||
until [[ $SUCCESS == "TRUE" ]]; do
|
until PID=$(pgrep xfce4-session); do
|
||||||
SUCCESS="FALSE"
|
echo "Rechecking dbus"
|
||||||
if test -f "$DBUS_FILE"; then SUCCESS="TRUE"; DBUS_ADDRESS=$(cat $DBUS_FILE); fi
|
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
# Export DBUS Variable
|
echo "DBUS PID: $PID"
|
||||||
echo "DBUS Address: $DBUS_ADDRESS"
|
sleep 5
|
||||||
export DBUS_SESSION_BUS_ADDRESS="unix:abstract=$DBUS_ADDRESS"
|
|
||||||
|
|
||||||
# Loop and check if its time to update the background
|
# Loop and check if its time to update the background
|
||||||
while true; do
|
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)
|
FILE_COUNT=$(ls *.jpg | wc -l)
|
||||||
IMAGE_NUMBER=$(bc -l <<< "x=( $(date +%H) / ( 24 / $FILE_COUNT )); scale=0; x/1+1")
|
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
|
if [[ $FILE != $OLD_FILE ]]; then
|
||||||
echo "Setting new background to $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 $DIR/$FILE
|
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorscreen/workspace0/last-image -n -t string -s $FILE
|
||||||
OLD_FILE=$FILE
|
OLD_FILEx=$FILE
|
||||||
fi
|
fi
|
||||||
sleep 60
|
sleep 60
|
||||||
done
|
done
|
||||||
Loading…
Reference in New Issue