3

I've been trying to figure out how to lock the screen in XUbuntu 16.04 and I can't seem to make anything work. Various posts suggest using the settings under 'Power Manager' and 'Light Locker Settings', which have selectors to enable and disable the screensaver, and I've tried all possible combinations of them, but none of them do anything.

Other places suggest running xflock4 or hitting ctrl-alt-del (which on the keyboard shortcuts runs xflock4), but that also does nothing. There's also no documentation for xflock4 (man xflock4 says "No manual entry" and xflock4 --help does nothing.)

Update

After poking around things for awhile, I fould dm-tool which has a lock option. Running dm-tool lock from a terminal successfully locks the screen. I can also set the keyboard shortcuts to make ctrl-alt-del run dm-tool lock, so I can now lock the screen with a key combo.

However, I still can't figure out how to get it to lock the screen after a timeout...

3 Answers 3

3

Here's the default Xubuntu setup:

  • light-locker is set to autostart because it must be running in the background to work
  • Keyboard shortcuts for Ctrl+Alt+Del and Ctrl+Alt+L are configured that call xflock4
  • xflock4 calls light-locker to lock the screen

If you run xflock4 in a terminal and nothing happens, odds are light-locker isn't running. The solution more or less is to restore the default settings:

  1. Remove light-locker-settings package. It's not necessary because screen lock settings are handled by Xfce Power Manager (as you can see in the screenshot you posted)

    sudo apt remove light-locker-settings
    
  2. Make sure essential packages are installed (just to be safe)

    sudo apt install light-locker xfce4-power-manager xfce4-session
    
  3. Reset light-locker settings

    sudo dpkg-reconfigure light-locker
    
  4. Remove any autostart overrides

    rm ~/.config/autostart/light-locker.desktop
    

    (This can be removed because the light-locker package installs a default autostart file here: /etc/xdg/autostart/light-locker.desktop)

  5. Reset the LockCommand setting in case it's been overrriden

    xfconf-query -c xfce4-session -p /general/LockCommand -r
    

    (xflock4 is just a shell script that will first look at LockCommand to see what command to run, falling back to light-locker if it isn't set)

  6. Reset keyboard shortcuts

    • If you're not worried about losing any other custom keyboard shortcuts, you can just reset them all to default:

      xfconf-query -c xfce4-keyboard-shortcuts -p / -rR
      
    • Otherwise, these are the specific keyboard shortcuts Xubuntu sets by default for screen locking:

      xfconf-query -c xfce4-keyboard-shortcuts -p "/commands/custom/<Primary><Alt>Delete" -s "xflock4" -n -t string
      xfconf-query -c xfce4-keyboard-shortcuts -p "/commands/custom/<Primary><Alt>l" -s "xflock4" -n -t string
      xfconf-query -c xfce4-keyboard-shortcuts -p "/commands/default/<Primary><Alt>Delete" -s "xflock4" -n -t string
      xfconf-query -c xfce4-keyboard-shortcuts -p "/commands/default/<Primary><Alt>l" -s "xflock4" -n -t string
      
  7. Log out and log back in. This will make sure light-locker autostart is working and also may be necessary for the keyboard shortcuts to refresh.

  8. Make sure light-locker is running

    $ ps -e | grep light-locker
     1869 ?        00:00:00 light-locker
    
  9. Make sure xflock4 locks the screen

    xflock4
    
  10. Make sure the keyboard shortcuts to lock the screen work

    • Ctrl+Alt+Del
    • Ctrl+Alt+L
  11. Lastly, if you want the screen to automatically lock after a certain time

    1. Open the menu > Settings > Power Manager > Security

    2. Automatically lock the session > When the screensaver is activated

    3. If you want to have a real screensaver, you'll need to install and configure xscreensaver or gnome-screensaver. Otherwise if you're okay with a blank screen, go to the Display tab in Power Manager and adjust the times as desired

2
  • Thank you very much. This was very helpful especially step 11. Because it describes the relation between security and display settings. I was confused about the "When screensaver is acivated" and there is no screensaver installed. But when realizing that black sreen on display tab is meant by that all made sense to me. :-)
    – sjuk
    Apr 11, 2020 at 15:10
  • @sjuk It's actually much simpler than it seems! xflock4 is just a shell script that will first try the command set in LockCommand (in newer versions), then xscreensaver, then light-locker, then gnome-screensaver: git.xfce.org/xfce/xfce4-session/tree/scripts/xflock4
    – bmaupin
    Apr 14, 2020 at 19:08
2

To lock the screen in xubuntu:

Ctrl+Alt+L

Note: The time os the button matters, try it several times to get it right.

Image: see line xflock4 Ctrl+Alt+L

enter image description here

2
  • No effect. The keyboard display on my machine only shows Ctrl+Alt+Delete for xlock4 (which also has no effect)
    – Chris Dodd
    Feb 16, 2017 at 3:49
  • please post an image if possible... Feb 16, 2017 at 6:25
0

Have a look at xautolock to lock after a timeout. Or xss-lock to lock when lid is closed and when the "blank after" timeout expires.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .