Cinnamon : Use the login screen / greeter as the lock screen

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
User avatar
smurphos
Level 19
Level 19
Posts: 9184
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Cinnamon : Use the login screen / greeter as the lock screen

Post by smurphos »

If for any reason you would prefer Cinnamon to display the login-screen / greeter instead of the default Cinnamon lock-screen when a session is locked this script is your friend.

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
Use Startup applications to make a custom entry to start the script on user login (with a short start-up delay of maybe 5 seconds)
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
User avatar
Pintjebier
Level 1
Level 1
Posts: 5
Joined: Fri Nov 29, 2024 2:37 am
Location: Belgium

Re: Cinnamon : Use the login screen / greeter as the lock screen

Post by Pintjebier »

This is what I was looking for, for a long time :D! Hopefully the Linux Mint devs will add this as an extra option in the screensaver settings to disable the original lock-screen. :idea:
Thank you so much!
Last edited by Pintjebier on Fri Nov 29, 2024 4:03 am, edited 2 times in total.
User avatar
Pintjebier
Level 1
Level 1
Posts: 5
Joined: Fri Nov 29, 2024 2:37 am
Location: Belgium

Re: Cinnamon : Use the login screen / greeter as the lock screen

Post by Pintjebier »

Forgot to mention, don't forget to add yourself to the 'audio' group with: usermod -a -G audio $user and then reboot.
If you don't perform this action, Spotify for example will stop playing audio when the screen locks.
User avatar
smurphos
Level 19
Level 19
Posts: 9184
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Cinnamon : Use the login screen / greeter as the lock screen

Post by smurphos »

Pintjebier wrote: Sun Dec 01, 2024 5:34 am Forgot to mention, don't forget to add yourself to the 'audio' group with: usermod -a -G audio $user and then reboot.
If you don't perform this action, Spotify for example will stop playing audio when the screen locks.
Good tip, I didn't know that.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
Post Reply

Return to “Tutorials”