Created
July 17, 2019 01:18
-
-
Save wfpaisa/e13db5178fcf6f2d8a38e034a1a95db6 to your computer and use it in GitHub Desktop.
Change wallpaper at night gnome cron
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 | |
# | |
# 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