Skip to content

Instantly share code, notes, and snippets.

@cletusw
Created October 30, 2015 20:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cletusw/bcbd8d2d0559f9ab56fc to your computer and use it in GitHub Desktop.
Save cletusw/bcbd8d2d0559f9ab56fc to your computer and use it in GitHub Desktop.
Change your background at a specific time (Mac OS X). Use `crontab -e` to edit your crontab:
0 10 * * * osascript ~/bin/Flow.scpt
0 12 * * * osascript ~/bin/No\ Flow.scpt
30 14 * * * osascript ~/bin/Flow.scpt
30 16 * * * osascript ~/bin/No\ Flow.scpt
tell application "Finder"
-- wrapped in a try block for error suppression
try
set mainDisplayPicture to "/Users/claytonwatts/Pictures/Flow.jpg"
-- 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 1 to (count theDesktops)
-- apply image to desktop
set picture of item x of the theDesktops to mainDisplayPicture
end repeat
end if
end tell
end try
end tell
tell application "Finder"
-- wrapped in a try block for error suppression
try
set mainDisplayPicture to "/Users/claytonwatts/Pictures/No Flow.jpg"
-- 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 1 to (count theDesktops)
-- apply image to desktop
set picture of item x of the theDesktops to mainDisplayPicture
end repeat
end if
end tell
end try
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment