It runs in the background and monitors for Cinnamon Screensaver becoming active. When the screensaver is activated the script will switch the user to the login-screen / greeter, and ensure that the session is actually locked.
Potential use cases.
1) Some people dislike the aesthetic differences between the greeter screen and the lock-screen.
2) The greeter background is displayed rather than a user background.
3) For multi-user computers, it saves one step for a second user to login to their own session from a locked machine.
Side effects.
1) Background media (e.g. music) will not continue to play when the screen lock kicks in.
2) Someone with physical access to the PC may be able to very briefly (milli-seconds) see the desktop using Ctrl-Alt-F7 from the greeter screen.
Save the script in
~/.local/bin
and make it executable.Code: Select all
#!/bin/bash
for PID in $(pidof -o %PPID -x "${0##*/}"); do
if [ "$PID" != $$ ]; then
kill -9 "$PID"
fi
done
ACTIVE=false
dbus-monitor --session "interface='org.cinnamon.ScreenSaver', member='ActiveChanged'" | while read -r STATE
do
if echo "$STATE" | grep -q "boolean true"; then
if ( ! $ACTIVE ) ; then
ACTIVE=true
dm-tool switch-to-greeter
cinnamon-screensaver-command -l
fi
elif ( $ACTIVE ) ; then
ACTIVE=false
fi
done