Last active
June 20, 2018 11:02
-
-
Save Bonno/5b1ffd28cc7c8a57c241 to your computer and use it in GitHub Desktop.
To use in cron or other trigger.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (* | |
| Script by Bonno Nachtegaal-Karels, June 2014 | |
| Based on OS-X-Wallpaper-Changer (https://github.com/pipwerks/OS-X-Wallpaper-Changer) by Philip Hutchison | |
| This script assumes: | |
| 1. You have a folder named "Wallpapers" in your Pictures folder or somewhere else depending on the setting below | |
| 2. You have images inside each folder | |
| For example: | |
| /Users/YOUR_USER_NAME/Pictures/Wallpapers/Time of Day/Afternoon Early/image.jpg | |
| GeekTool can execute this script for you at specified intervals. Use this line in the command field: | |
| osascript ~/Pictures/Wallpapers/Time\ of\ Day/wallpaper.scpt | |
| *) | |
| -- BEGIN USER CONFIGURATION | |
| -- supply wallpaper folder | |
| set wallPaperFolder to "Graphics_MultiMedia:Wallpapers:_Rotator" | |
| -- for multiple monitor support. | |
| -- set to true to display the same image on all desktops, false to show unique images on each desktop | |
| set useSamePictureAcrossDisplays to true | |
| -- END USER CONFIGURATION | |
| -- helper function ("handler") for getting random image | |
| on getImage(wallPaperFolder) | |
| tell application "Finder" | |
| return some file of folder (wallPaperFolder) of home as text | |
| end tell | |
| end getImage | |
| tell application "Finder" | |
| -- wrapped in a try block for error suppression | |
| try | |
| -- determine which picture to use for main display | |
| set mainDisplayPicture to my getImage(wallPaperFolder) | |
| -- set the picture for additional monitors, if applicable | |
| tell application "System Events" | |
| -- get a reference to all desktops | |
| set theDesktops to a reference to every desktop | |
| -- handle additional desktops | |
| if ((count theDesktops) > 1) then | |
| -- loop through all desktops (beginning with the second desktop) | |
| repeat with x from 2 to (count theDesktops) | |
| -- determine which image to use | |
| if (useSamePictureAcrossDisplays is false) then | |
| set secondaryDisplayPicture to my getImage(wallPaperFolder) | |
| else | |
| set secondaryDisplayPicture to my mainDisplayPicture | |
| end if | |
| -- apply image to desktop | |
| set picture of item x of the theDesktops to secondaryDisplayPicture | |
| end repeat | |
| end if | |
| end tell | |
| -- set the primary monitor's picture | |
| -- due to a Finder quirk, this has to be done AFTER setting the other displays | |
| set desktop picture to mainDisplayPicture | |
| end try | |
| end tell |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Rotate wallpaper in Ubuntu | |
| WALLPAPER_DIR=~/Pictures/wallpaper | |
| while true | |
| do | |
| image=`ls $WALLPAPER_DIR | shuf -n 1` | |
| echo "Changing to image $image" | |
| gsettings set org.gnome.desktop.background picture-uri "file://$WALLPAPER_DIR/$image" | |
| sleep 60 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment