Last active
April 2, 2020 13:01
-
-
Save IamFaizanKhalid/0014cd09fbc4a819ce97f19d03126837 to your computer and use it in GitHub Desktop.
Random Wallpaper from Unsplash
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
#!/usr/bin/env bash | |
usage() { | |
printf "Usage: $0 [-d] [ -p PATH | -t ] [ -o FILENAME ] [ -r RESOLUTION ]\n\n" | |
printf "\t-d to just download the image\n" | |
printf "\t-p to save image on specific path.\n" | |
printf "\t-p to save image in /tmp.\n" | |
printf "\t-o to save image with specific name.\n" | |
printf "\t-r to set custom resoltion for image.\n\n" | |
printf "Example:\n" | |
printf "\twallpaper -d -p ~/Desktop -o my-wallpaper -r 1300x720\n\n" | |
exit 2 | |
} | |
DIRECTORY=/media/faizan/Data/Pictures/Wallpapers/Unsplash | |
FILENAME="unsplash_$(date +"%F_%H-%M-%S")" | |
EXTENSION="jpg" | |
RESOLUTION="1920x1080" | |
DOWNLOAD_ONLY=false | |
while getopts "dp:o:?h" opt; do | |
case $opt in | |
d) DOWNLOAD_ONLY=true ;; | |
p) DIRECTORY=$OPTARG ;; | |
t) DIRECTORY=/tmp ;; | |
o) FILENAME=$OPTARG ;; | |
r) RESOLUTION=$OPTARG ;; | |
h | ?) usage ;; | |
esac | |
done | |
OUTPUT_FILE=$DIRECTORY/$FILENAME.$EXTENSION | |
wget -O $OUTPUT_FILE https://source.unsplash.com/random/$RESOLUTION | |
if [ $? -ne 0 ] || [ $DOWNLOAD_ONLY = false ]; then | |
gsettings set org.gnome.desktop.background picture-uri $OUTPUT_FILE | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment