Created
September 5, 2021 16:48
-
-
Save RazorSh4rk/b7c0549d0b99f7b979536f02c09b4f04 to your computer and use it in GitHub Desktop.
Set a random wallpaper from unsplash on xfce
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 | |
if [[ $1 == "" ]]; then | |
QUERY="neon" | |
else | |
QUERY=$1 | |
fi | |
echo "► searching for $QUERY" | |
API_KEY="YOUR UNSPLASH API KEY" | |
IDX=$(($RANDOM % 5)) | |
URL="https://api.unsplash.com/search/photos?page=1&query=$QUERY&order_by=latest&orientation=landscape&per_page=5&client_id=$API_KEY" | |
FPATH="/tmp/wallpaper.jpg" | |
IMG_URL=$(curl \ | |
-s \ | |
--request GET \ | |
--url $URL \ | |
| jq -r .results[$IDX].urls.full) | |
echo "► got image $IMG_URL" | |
wget --no-cache -O $FPATH $IMG_URL -q | |
echo "► setting wallpaper..." | |
xfconf-query \ | |
-c xfce4-desktop \ | |
-p /backdrop/screen0/$(xrandr|awk '/\<connected/{print "monitor"$1}')/workspace0/last-image \ | |
-s $FPATH | |
sleep 1 | |
# rm $FPATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment