2
1
I am new to using Automator. I'm trying to make my desktop wallpaper change according to my screen brightness which is automatically adjusting to the light in my room (basically an automatic bright/dark mode for the desktop).
Is there anything like Folder Action that is triggered by a custom event instead of by adding files to a folder? I need it to trigger when the screen brightness changes, and then depending on the brightness decide if the wallpaper needs to be changed.
What I have so far
The following AppleScript does everything I need:
set brightness to do shell script "nvram backlight-level | awk '{print $2}'"
if brightness is equal to "8%00" or brightness is equal to "%16%00" or brightness is equal to "%25%00" or brightness is equal to "%00%00" then
setWallpaper("dark")
else
setWallpaper("bright")
end if
on setWallpaper(imageName)
tell application "System Events"
tell every desktop
set picture to "/Users/Ryn/Desktop/wallpapers/" & imageName & ".png"
end tell
end tell
end setWallpaper
The only thing left is to figure out how to run it every time the screen brightness changes.