Skip to content

Instantly share code, notes, and snippets.

@Limych
Last active April 28, 2021 00:59
Show Gist options
  • Save Limych/1ebb913ab57a87ce512bb72a5dca1807 to your computer and use it in GitHub Desktop.
Save Limych/1ebb913ab57a87ce512bb72a5dca1807 to your computer and use it in GitHub Desktop.
Rotate best Earth photos as desktop background on Ubuntu
#!/usr/bin/env bash
# Rotate best Earth photos as desktop background on Ubuntu.
#
# Just run this file via crontab. As example for every hour rotation:
# 0 * * * * ~/change_bg.sh
#
# Source: https://gist.github.com/Limych/1ebb913ab57a87ce512bb72a5dca1807
user=$(whoami)
fl=$(find /proc -maxdepth 2 -user $user -name environ -print -quit)
while [ -z $(grep -z DBUS_SESSION_BUS_ADDRESS "$fl" | cut -d= -f2- | tr -d '\000' ) ]
do
fl=$(find /proc -maxdepth 2 -user $user -name environ -newer "$fl" -print -quit)
done
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS "$fl" | cut -d= -f2-)
wget -O - -q reddit.com/r/earthporn.json | jq '.data.children[] |.data.url' | grep -v 'reddit.com' | shuf -n 1 | xargs gsettings set org.gnome.desktop.background picture-uri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment