fixing time calculation to background image

This commit is contained in:
devindice 2022-08-06 11:22:54 -04:00
parent 5f35f7b731
commit 9f225254b9

View file

@ -2,21 +2,23 @@ OLD_FILE=""
DBUS_FILE="/var/log/dbus.txt"
DIR=$(pwd)
# Wait until dbus is listening and delay 5 seconds for it to fully start.
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
#sleep 1
echo "DBUS Address: $DBUS_ADDRESS"
export DBUS_SESSION_BUS_ADDRESS="unix:abstract=$DBUS_ADDRESS"
export DISPLAY=:1.0
sleep 1
done
# Export DBUS Variable
echo "DBUS Address: $DBUS_ADDRESS"
export DBUS_SESSION_BUS_ADDRESS="unix:abstract=$DBUS_ADDRESS"
# Loop and check if its time to update the background
while true; do
echo $(date)
FILE_COUNT=$(ls *.jpg | wc -l)
IMAGE_NUMBER=$(bc -l <<< "x=( $(date +%H) / ( 24 / $FILE_COUNT )); scale=0; x/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")
if [[ $FILE != $OLD_FILE ]]; then
echo "Setting new background to $FILE"