Skip to content

Instantly share code, notes, and snippets.

@wfpaisa
Created July 17, 2019 01:18
Show Gist options
  • Save wfpaisa/e13db5178fcf6f2d8a38e034a1a95db6 to your computer and use it in GitHub Desktop.
Save wfpaisa/e13db5178fcf6f2d8a38e034a1a95db6 to your computer and use it in GitHub Desktop.
Change wallpaper at night gnome cron
#!/bin/bash
#
# Cron
#
# 1. Create a file call it `/home/USER/changewallpaper` whit all this content
# 2. Execute with `chmod +x /home/USER/changewallpaper`
# 3. Create or edit the cron with `crontab -e`
# 4. add `0 * * * * /home/USER/changewallpaper`
#
# where (minute|hour|day-month|month|week) chek https://crontab.guru/
# check all crontab `crontab -l`
#
# It's requeried for setup a bus session
EUID=$(id --real --user)
PID=$(pgrep --euid $EUID gnome-session)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)
# Check the hour and set the wallpaper
HOUR=$(date +%H)
case "$HOUR" in
06|07|08|09|10|11|12|13|14|15|16|17)
gsettings set org.gnome.desktop.background picture-uri "/home/USER/Pictures/wallpaper.jpg"
;;
# 16|17|18)
# gconftool -t string -s /desktop/gnome/background/picture_filename PATH-TO-SUNSET-PICTURE
# ;;
*)
gsettings set org.gnome.desktop.background picture-uri "/home/USER/Pictures/wallpaper-dark.jpg"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment