Advertisement
dado3212

Change Wallpaper Script

Mar 1st, 2017
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.85 KB | None | 0 0
  1. #!/bin/bash
  2. # Get the current date
  3. DATE=`date +"%H"`
  4. NAME="Sunrise.jpg"
  5.  
  6. BASE_FOLDER=`dirname $0`
  7.  
  8. # Figure out the image that it should be
  9. if [ "$DATE" -ge 5 ] && [ "$DATE" -lt 10 ]; then # 5am to 10am
  10.   NAME="Sunrise.jpg"
  11. elif [ "$DATE" -ge 10 ] && [ "$DATE" -lt 16 ]; then # 10am to 4pm
  12.   NAME="Day.jpg"
  13. elif [ "$DATE" -ge 16 ] && [ "$DATE" -lt 21 ]; then # 4pm to 9pm
  14.   NAME="Sunset.jpg"
  15. elif [ "$DATE" -ge 21 ] || [ "$DATE" -lt 5 ]; then # 9pm to 5am
  16.   NAME="Night.jpg"
  17. fi
  18.  
  19. # Figure out the current one
  20. CURRENT=`sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "select value from data" | sed 's,'"$BASE_FOLDER/\(.*\)"',\1,' | uniq`
  21.  
  22. # If they're different, update!
  23. if [[ $NAME != $CURRENT ]]; then
  24.   sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '$BASE_FOLDER/$NAME'" && killall Dock
  25. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement