Skip to content

Instantly share code, notes, and snippets.

@oesmith
Created October 19, 2021 09:11
Show Gist options
  • Save oesmith/0120848c45df407b96de383a636f4634 to your computer and use it in GitHub Desktop.
Save oesmith/0120848c45df407b96de383a636f4634 to your computer and use it in GitHub Desktop.
Automatically downloads today's wallpaper from Bing (bash + curl + jq)
#!/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