I want to setup a cron job to lock my session every day at three PM. When I enter dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock
in a terminal window, the session locks immediately, but when I do the same in crontab (even by using a BASH script) it didn't work.
I want to create a BASH script to lock the session using dbus-send
and add it to crontab
.
Using loginctl to lock your desktop screen from crontab.
/opt/bin/lock-session.sh: