You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.1 KiB
57 lines
1.1 KiB
#!/usr/bin/env bash |
|
|
|
NOTIFY="FALSE" |
|
IMAGE="RANDOM" |
|
|
|
function get_random_slug(){ |
|
curl -s "https://earthview.withgoogle.com/" | hq 'a.intro__explore' attr href |
|
} |
|
|
|
function notification(){ |
|
notify-send "$( jq -r '.name' /tmp/backgroundinfo.json)" |
|
} |
|
|
|
function set_random_image(){ |
|
set_specific_image "$slug" |
|
} |
|
|
|
function download_image(){ |
|
if [ "$IMAGE" == "RANDOM" ]; then |
|
local slug=$(get_random_slug) |
|
else |
|
local slug="$IMAGE" |
|
fi |
|
curl -s "https://earthview.withgoogle.com/_api${slug}.json" > /tmp/backgroundinfo.json |
|
image=$( jq -r '.photoUrl' /tmp/backgroundinfo.json ) |
|
curl -s -o /tmp/background.jpg "$image" |
|
} |
|
|
|
function set_image(){ |
|
download_image |
|
if command -v nitrogen > /dev/null; then |
|
nitrogen --set-zoom-fill /tmp/background.jpg |
|
elif command -v nitrogen > /dev/null; then |
|
feh --bg-fill /tmp/background.jpg |
|
else |
|
echo "No wallpaper tools found" |
|
fi |
|
if [ "$NOTIFY" == "TRUE" ]; then |
|
notification |
|
fi |
|
} |
|
|
|
while [ -n "$1" ]; do |
|
case "$1" in |
|
"--notify") |
|
NOTIFY="TRUE" |
|
shift |
|
;; |
|
"--only-notify") |
|
notification |
|
shift |
|
exit 0 |
|
;; |
|
esac |
|
done |
|
|
|
set_image
|
|
|