20

Like gnome Control + alt + L

In Lxde how can i do that? What I have to intall to do this?

thanks

--searching for a solution on my own but...

ok if I do alt+f2 and type xscreensaver-command -lock that's a small solution. tryed to do an small script but it's not working..

this is what I do

vi lock.sh

#!/bin/bash
xscreensaver-command -lock
exit 0

chmod +x lock.sh

but this doesnt work.. ideas?

0

4 Answers 4

29

You should be able to bind the screensaver lock command to CTRL+ALT+L by editing your Lubuntu keyboard & mouse configuration file

Add the following to ~/.config/openbox/lubuntu-rc.xml

<keybind key="C-A-L">      
  <action name="Execute">        
    <command>xscreensaver-command -lock</command>      
  </action>    
</keybind>

This should be located inbetween the XML tags

<keyboard>
...
</keyboard

enter image description here

Logout and login for the changes to take effect.

4
  • 14
    Type openbox --reconfigure in terminal for changes to take effect. This is GNU/Linux we're talking about—logout/login is superfluous.
    – Richard
    Feb 27, 2012 at 18:17
  • Be careful not to use $HOME=/root for your rc file, but your real user.
    – Timo
    Dec 9, 2017 at 8:35
  • 2
    @Richard, or openbox --restart to get it done.
    – Timo
    Dec 9, 2017 at 8:36
  • Place this between the </keyboard> -- that's really important tip. Thanks! Apr 12, 2021 at 6:38
24

I would elaborate/combine some of the answers. First (in a terminal) start your editor:

vi ~/.config/openbox/lubuntu-rc.xml

Then search for the mentioned faulty code:

<keybind key="C-A-L">      
  <action name="Execute">        
    <command>xscreensaver-command -lock</command>      
  </action>    
</keybind>

and change it to use the dm-tool:

<keybind key="C-A-L">      
  <action name="Execute">        
    <command>dm-tool lock</command>      
  </action>    
</keybind>

Then add a section, so the Windows+L combination works too:

<keybind key="W-L">
  <action name="Execute">        
    <command>dm-tool lock</command>      
  </action>    
</keybind>

Finally, finish the editor (saving the file) and activate it:

openbox --reconfigure

Good luck and thanks for all the answers found here...

2
  • 3
    this should be the answer
    – a06e
    May 19, 2014 at 16:06
  • I already had dm-tool installed by default. I would have had to install xscreensaver for the accepted answer to work. -Thanks
    – Usagi
    Jul 28, 2016 at 17:03
9

We can also use "lxlock" command that's provided by the lxde. I just found it on Ubuntu 14.04. We can add the below lines in our openbox config file in the keyboard. vim $HOME/.config/openbox/lubuntu-rc.xml

<!-- keybinding for Screen Lock-->
    <keybind key="W-L">
        <action name="Execute">
          <command>lxlock</command>
        </action>

And then restart the openbox with the following command.

openbox --restart

This will enable locking of the desktop by hitting Windows Key + L

3
  • To clarify for readers: lxlock is installed in /usr/bin as a shell script that tries to identify/invoke various common screensaver/lock options that might coexist on the system. If if it doesn't find any other options, it will fallback to xscreensaver-command -lock anyway. Personally I find it easier and more (hypothetically) cross-platform to go straight to X, and a screen lock really isn't somewhere that I care about eye-candy! Sep 5, 2015 at 23:18
  • confirmed for Lubuntu Trusty
    – user14654
    Dec 29, 2015 at 22:11
  • Using lxlock solves the problem in Lubuntu 14.04.03 LTS
    – Kadir
    Jan 25, 2016 at 15:11
3
  1. I'm not good at scripts but I would do it like this (and it should work):
    lock.sh contents:

    xscreensaver-command -lock
    

    In terminal:

    sh ./lock.sh
    
  2. Better way is to create a .desktop file (which you can place on panel inside of "Application launch bar" applet, and it will be in main menu all the time). In /usr/share/applications create file lock.desktop and it should contain:

    [Desktop Entry]   
    Type=Application   
    Icon={path to icon you like}   
    Name={what would you like to name it}   
    Categories=Utility; {this will place it in Accessories menu in your main menu}  
    Exec=xscreensaver-command -lock  
    NoDisplay=false {if you set this to true you will not see it in menu and while adding to panel}   
    

Save it and it should appear in menu (maybe after few seconds)

2
  • you're welcome. If you run into any troubles with this, write here, will help as much as I can
    – foxy
    Nov 17, 2011 at 15:59
  • About the keybinding (sorry, can't commit on others' answers): you should just copy the text which fossfreedom posted in that place, it's not there yet.
    – foxy
    Nov 17, 2011 at 19:03

You must log in to answer this question.

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