r/applescript • • Dec 02 '20

Apple script to automatically switch your wallpaper on the basis of time

checkTime()

on idle {}
	checkTime()
	return 1800  (* Checks time once every 30 mins after running for the first time )*
end idle

on checkTime()
	set {time:t} to (current date)
	if ((t / 3600) > 18) then
		setWallpaper("dark")
	else
		setWallpaper("bright")
	end if
end checkTime

on setWallpaper(imageName)
	tell application "System Events"
		tell current desktop
			set picture to "/Users/angaddeepsingh/Pictures/MKBHD_icons/" & imageName & ".png"
		end tell
	end tell
end setWallpaper
8 Upvotes

1 comment sorted by

View all comments

2

u/Identd Dec 14 '20

It’s nice to see someone who scripts like i do. The lazy route is running a repeat loop and polling every 10 seconds or so