Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Get the current date
- DATE=`date +"%H"`
- NAME="Sunrise.jpg"
- BASE_FOLDER=`dirname $0`
- # Figure out the image that it should be
- if [ "$DATE" -ge 5 ] && [ "$DATE" -lt 10 ]; then # 5am to 10am
- NAME="Sunrise.jpg"
- elif [ "$DATE" -ge 10 ] && [ "$DATE" -lt 16 ]; then # 10am to 4pm
- NAME="Day.jpg"
- elif [ "$DATE" -ge 16 ] && [ "$DATE" -lt 21 ]; then # 4pm to 9pm
- NAME="Sunset.jpg"
- elif [ "$DATE" -ge 21 ] || [ "$DATE" -lt 5 ]; then # 9pm to 5am
- NAME="Night.jpg"
- fi
- # Figure out the current one
- CURRENT=`sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "select value from data" | sed 's,'"$BASE_FOLDER/\(.*\)"',\1,' | uniq`
- # If they're different, update!
- if [[ $NAME != $CURRENT ]]; then
- sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '$BASE_FOLDER/$NAME'" && killall Dock
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement