Created
October 19, 2021 09:11
-
-
Save oesmith/0120848c45df407b96de383a636f4634 to your computer and use it in GitHub Desktop.
Automatically downloads today's wallpaper from Bing (bash + curl + jq)
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
#!/bin/bash | |
set -ex | |
api_url="https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US" | |
base_url="https://www.bing.com" | |
output=$HOME/wallpapers/bing-wallpaper.jpg | |
# Fetch the URL from the Bing API endpoint. | |
url_path=$(curl -s "$api_url" | jq -r ".images[0].url") | |
# Download the image to $output. | |
curl -L -o "${output}" "${base_url}${url_path}" | |
# Tell sway to reload the wallpaper. | |
swaymsg reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment