Skip to content

Instantly share code, notes, and snippets.

@erfanium
Created January 7, 2023 23:15
Show Gist options
  • Save erfanium/3b5957cfdc867d8ac475efeea6f1f684 to your computer and use it in GitHub Desktop.
Save erfanium/3b5957cfdc867d8ac475efeea6f1f684 to your computer and use it in GitHub Desktop.
randomly change ubuntu background
# Generate the query string by concatenating the arguments with commas
QUERY=$(printf ',%s' "$@")
QUERY=${QUERY:1} # remove leading comma
# Use xrandr to get the screen resolution
SCREEN_RES=$(xrandr --current | grep '*' | uniq | awk '{print $1}')
# Download the wallpaper and set it as the background
wget -O /tmp/wallpaper.jpg "https://source.unsplash.com/$SCREEN_RES/?$QUERY"
gsettings set org.gnome.desktop.background picture-uri file:///tmp/wallpaper.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment