Skip to content

Instantly share code, notes, and snippets.

@fentas
Created February 12, 2019 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fentas/24e5a325e7414ba5f284cda683232e1f to your computer and use it in GitHub Desktop.
Save fentas/24e5a325e7414ba5f284cda683232e1f to your computer and use it in GitHub Desktop.
random unsplash wallpaper
#!/bin/sh
ids=(
"1111575" # space
"176" # unsplash
"562095" # Wilderness Artifacts
"164" # Brevitē
"151749" # Follow Me
"397770" # Coffee House
)
# wait for internet
until wget -q --spider "https://source.unsplash.com/"; do sleep 1; done
IFS=$'\n'
for screen in $(xrandr | grep -o 'Screen [0-9]*'); do
res="$(xrandr | grep "${screen}" | grep -oP 'current \K[0-9]+ x [0-9]+' | tr -d ' ')"
tmp="$(mktemp --suffix -wallpaper)"
col="${ids[ $RANDOM % ${#ids[@]} ]}"
curl -fsSLo "${tmp}" "https://source.unsplash.com/collection/${col}/${res}"
xwallpaper --screen "$(echo "${screen}" | grep -o '[0-9]*')" --stretch "${tmp}"
done
unset IFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment