Search code examples
macosapplescriptbackground-imagedesktop-background

Perform actions when background image changed on Mac


Is there any way to listen to, and trigger actions when user right click and click change desktop background OR when the background image is actually changed on OSX?


Solution

  • You can get the current desktop image in the shell like this:

    osascript -e 'tell app "finder" to get posix path of (get desktop picture as alias)'
    

    I presume, if you really wanted to, you could create a launchd script with launchctl and a corresponding plist to check every minute or so to see if it has changed and then do something...