sunwxg / gnome-shell-extension-unlockDialogBackground

MIT License
44 stars 9 forks source link

[Implementation] Example script to have rotating background photos (slideshow/carousel) #6

Open euh2 opened 5 years ago

euh2 commented 5 years ago

Thanks for this extension! I just want to share how I implemented it to suit my needs. I wanted a screen curtain/ screen shield with rotating photos (slideshow/ carousel), just like an idle Chromecast Display. I created a script which changes two gsettings keys. One key from this extension: org.gnome.shell.extensions.unlockDialogBackground picture-uri and one standard Gnome Shell key: org.gnome.desktop.screensaver picture-uri. This extensions key changes the unlock screen, while the standard (screensaver) key changes the screen shield. I have both set to the same photo every 5 min (trough a cron job) for consistency. The photos are randomly selected from a specified folder.

Here is the script (locks.sh):

#!/bin/bash
EUID=$(id --real --user)
PID=$(pgrep  --euid $EUID gnome-session)
# needed to have access to dbus though cron
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)

# xset s off    # This turns off the "screensaver" feature (not actually a screensaver, just an annoying power saving feature.)
# xset -dpms    # Turns off dpms (desktop power management system -- also annoying)
PHOTOS=/My/Photo/Folder/With/Awesome/Wallpapers/Just/Like/Chromecast/
RANDOM_PHOTO="$(find $PHOTOS -type f -print0 | shuf -zn1 | tr -d '\0')"
# echo $RANDOM_PHOTO # uncomment to test script
gsettings set org.gnome.desktop.screensaver picture-uri $RANDOM_PHOTO
gsettings --schemadir ~/.local/share/gnome-shell/extensions/unlockDialogBackground@sun.wxg@gmail.com/schemas/ \
set org.gnome.shell.extensions.unlockDialogBackground picture-uri $RANDOM_PHOTO

And the cron job every 5 min (command: crontab -e):

*/5 * * * * export DISPLAY=:0; /bin/bash /home/USERNAME/.scripts/lockscreen-slideshow/locks.sh

(For testing I piped the output to a logfile:)

*/5 * * * * export DISPLAY=:0; /bin/bash /home/USERNAME/.scripts/lockscreen-slideshow/locks.sh >> /tmp/locks.log 2>&1

I really enjoy the result!

sunwxg commented 5 years ago

Fantastic! Like some extension can update desktop background automatically.

mossad-zika commented 4 years ago

this should become a part of extension !

emoxam commented 1 month ago

pgrep --euid $EUID gnome-session

3696
3937
3957

grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ

grep: /proc/3696: Is a directory
grep: 3937: No such file or directory
grep: 3957/environ: No such file or directory

Is it ok ?