Last active
August 29, 2015 14:14
-
-
Save markomarkovic/3d06f491f8e8c9655829 to your computer and use it in GitHub Desktop.
Automatically switch desktop background to latest Bing image
This file contains 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
#!/usr/bin/env bash | |
# Fetches the latest Bing image and sets it as desktop background | |
# | |
# Requirements: | |
# curl, jq, nitrogen, convert (imagemagick) | |
# | |
# Installation: | |
# sudo cp switch-desktop-background /usr/local/bin/ | |
# sudo chmod +x /usr/local/bin/switch-desktop-background | |
# | |
# and run it using crontab every 6 hours | |
# crontab -e | |
# 0 */6 * * * /usr/local/bin/switch-desktop-background | |
## Bing feed URL | |
URL=http://www.bing.com/HPImageArchive.aspx\?format=js\&idx=0\&n=1 | |
## Get latest | |
DATA=`curl -s $URL` | |
## Save it to /tmp/background | |
echo $DATA | jq '@uri "http://www.bing.com/\(.images[0].url)"' | sed 's/_\(1920x1080\|1366x768\)/_1920x1200/' | xargs curl -so /tmp/background | |
## Overlay the description | |
DESC=`echo $DATA | jq -r .images[0].copyright` | |
convert /tmp/background -fill '#FFFFFF30' -undercolor '#00000030' -gravity SouthEast -annotate +5+30 "$DESC" /tmp/background | |
## Set the BG | |
DISPLAY=:0.0 nitrogen --set-zoom-fill /tmp/background |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment