fixing time calculation to background image
This commit is contained in:
parent
5f35f7b731
commit
9f225254b9
|
|
@ -2,21 +2,23 @@ OLD_FILE=""
|
||||||
DBUS_FILE="/var/log/dbus.txt"
|
DBUS_FILE="/var/log/dbus.txt"
|
||||||
DIR=$(pwd)
|
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
|
until [[ $SUCCESS == "TRUE" ]]; do
|
||||||
SUCCESS="FALSE"
|
SUCCESS="FALSE"
|
||||||
if test -f "$DBUS_FILE"; then SUCCESS="TRUE"; DBUS_ADDRESS=$(cat $DBUS_FILE); fi
|
if test -f "$DBUS_FILE"; then SUCCESS="TRUE"; DBUS_ADDRESS=$(cat $DBUS_FILE); fi
|
||||||
#sleep 1
|
sleep 1
|
||||||
echo "DBUS Address: $DBUS_ADDRESS"
|
|
||||||
export DBUS_SESSION_BUS_ADDRESS="unix:abstract=$DBUS_ADDRESS"
|
|
||||||
export DISPLAY=:1.0
|
|
||||||
done
|
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
|
# Loop and check if its time to update the background
|
||||||
while true; do
|
while true; do
|
||||||
echo $(date)
|
|
||||||
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")
|
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=$(ls -1 *.jpg | sed "${IMAGE_NUMBER}q;d")
|
||||||
if [[ $FILE != $OLD_FILE ]]; then
|
if [[ $FILE != $OLD_FILE ]]; then
|
||||||
echo "Setting new background to $FILE"
|
echo "Setting new background to $FILE"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue