I would like to set my desktop background to a webcam picture that updates several times an hour, for instance to this view of Tegernsee. I am looking for a way to automatically get that picture every couple of minutes from the internet and update the desktop background. How can I do that (I would prefer a bash or applescript solution)?
Autoupdate the desktop background from an online photo webcam
desktopwebcam
Related Question
- My desktop background won’t change automatically. OS X 10.6.7
- How to programmatically get the path to the wallpaper on the active desktop
- MacOS – Can’t Set Desktop Background in Fullscreen App
- How to automatically fetch images from a website and update desktop image to match (in terminal)
- MacOS – How to set ‘fit to screen’ as the default behaviour when changing the desktop background (wallpaper)
- Is there way to crop the output of a camera for a video chat
- MacOS – How to disable auto-exposure adjusting for the webcam
Best Answer
I have found a way to make this work with launchd. This requires two steps: First creating a script that downloads the webcam picture, and second creating a LaunchAgent plist file that will call the script every so often.
This method will update the background picture of a specific Space, but only while you are on that space (also, when logging in and maybe when waking from sleep).
First step: Creating a script that downloads the picture and changes the desktop background
~/Library/Desktop Pictures/Webcam
.Write a text file with the following content:
Save the file, e.g. as
~/Library/Desktop Pictures/Webcam/getwebcam.sh
Make it executable by issuing the following command in the Terminal:
Second step: Creating a LaunchAgent plist that calls the script
Write a text file with the following content. You need to adapt the string
/Users/myusername/Library/Desktop Pictures/Webcam/getwebcam.sh
so it points to the script created in the first step. You cannot use a relative path with~
. Change the dict elements with the "Minute" key as you see fit – you can add more of them. The integer determines at which minute of every hour the script will be called (see alsoman launchd.plist
on your Terminal).Save the text file to
~/Library/LaunchAgents/me.myname.update-desktop-from-webcam.plist
– the name should match the "Label" key in the file.Load it by issuing the following command: