Last active
February 20, 2025 21:54
-
-
Save caspar/245933a11488fb4a8cbc7e2a51a107a6 to your computer and use it in GitHub Desktop.
Austrian Alps live webcam wallpaper (Mac)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<!-- Put this script in ~/Library/LaunchAgents/ --> | |
<!-- ========================================================================== --> | |
<!-- IMPORTANT: After making changes to this script, run the following --> | |
<!-- commands to load the changes: --> | |
<!-- | |
launchctl unload ~/Library/LaunchAgents/com.user.updatewallpaper.plist | |
launchctl load ~/Library/LaunchAgents/com.user.updatewallpaper.plist | |
--> | |
<!-- ========================================================================== --> | |
<key>Label</key> | |
<string>com.user.updatewallpaper</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/bin/bash</string> | |
<string>~/Scripts/update_wallpaper.sh</string> | |
</array> | |
<key>StartInterval</key> | |
<integer>300</integer> <!-- Run the script every 300 seconds --> | |
<!-- run script on boot --> | |
<key>RunAtLoad</key> | |
<true/> | |
<!-- run script on wake --> | |
<key>StartOnMount</key> | |
<true/> | |
<key>StandardOutPath</key> | |
<string>/tmp/update_wallpaper.log</string> <!-- Log output --> | |
<key>StandardErrorPath</key> | |
<string>/tmp/update_wallpaper_error.log</string> <!-- Log errors --> | |
</dict> | |
</plist> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# run this script every 10 minutes | |
# .plist is located in ~/Library/LaunchAgents/ | |
# put this script in ~/Scripts | |
# time rounded to 10th minute, formatted like: 2025/02/11/21xx | |
NOW=$(date +"%Y/%m/%d/%H%M") | |
# with timezone correction (usually off) | |
# NOW=$(TZ=Europe/Vienna date +"%Y/%m/%d/%H%M") | |
# change last digit to 0 | |
NOW=${NOW%?}0 | |
echo "datetime: " $NOW | |
# array of webcams | |
VIEWS=("mooserboden" "trafoi") | |
WEBCAM_URL="https://www.foto-webcam.eu/webcam/mooserboden/${NOW}_uh.jpg" | |
echo $WEBCAM_URL | |
# if code 502 bad gateway, don't update wallpaper | |
if curl -s --head --request GET $WEBCAM_URL | grep "502 Bad Gateway" > /dev/null | |
then | |
# throw error | |
echo "502 Bad Gateway: No Image Found" | |
exit 1 | |
fi | |
# Set the image as the desktop background using desktopper | |
/usr/local/bin/desktoppr "$WEBCAM_URL" | |
# /usr/local/bin/desktoppr scale center | |
echo "Wallpaper updated at $(date)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment