Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there any way that I can lock the screen CLI-style? I'm trying to target as many desktop managers as possible (mostly LightDM, but GDM, KDM, SLiM, XScreensaver, etc. would be great too), but I can only dig things up for GDM and XScreensaver.

For GDM, it would be:

gnome-screensaver-command -l

For XScreensaver:

xscreensaver-command -lock

Is there a similar command for KDM and LightDM?

share|improve this question
    
Can you start the screen saver and ssh in and ps and see what screen saver is running and deduce from there what command to run? (how I found the gnome-screensaver-command) –  polynomial Sep 30 '11 at 4:35
1  
man lightdm doesn't look too promising... moleberry.com/man/l/lightdm.1.html –  jasonwryan Sep 30 '11 at 5:41
    
Perhaps you can try to control them via d-bus (using dbus-send to send the appropriate lock message). –  andcoz Sep 30 '11 at 9:24
    
@andcoz: I saw a few dbus-send things while Googling, but sadly none of them worked. I even looked at the LightDM API reference for a solution, but even that doesn't have anything. Heck, I even tried to look at the source of Ubuntu's user switching panel (sorry, can't read like 1,000,000 of C). I might try emailing the dev list for help... –  Blender Sep 30 '11 at 15:48
    
@polynomial: That seems like a good solution (maybe post it as an answer?). I don't have a second computer to SSH with, but I can try and print the process list every second or so to deduce what is happening. –  Blender Sep 30 '11 at 15:51
show 1 more comment

3 Answers 3

up vote 3 down vote accepted

I Googled/emailed around a bit and got these two commands.

To lock the screen:

xflock4

To activate user switching:

gdmflexiserver

For Lightdm, this file resides in a strange spot (at least on Arch Linux):

/usr/lib/lightdm/lightdm/gdmflexiserver

I merged these two into XFCE's logout button dialog, in case anyone's interested, so the patch is available here: https://aur.archlinux.org/packages.php?ID=52816

share|improve this answer
add comment

There are several DM-independent, simple solutions like alock, slock or xtrlock (manpage). Note that they might not even display any input window prompting for password - you just enter the password while the screen is blank and press Enter (that's the case of slock at least).

If you want the locker to be able to display a screensaver and show a custom prompt on un-locking, try xlock provided with xlockmore package (see this info and the manpage).

share|improve this answer
    
I'm not looking for a lock screen (I have my own, plock, for that :P). I'm looking for a way to trigger the lockscreen (whatever it is). –  Blender Sep 30 '11 at 15:47
    
Then xautolock (which is a part of xlockmore) provides this functionality - have a look at the last two links I posted and the xautolock manpage. –  rozcietrzewiacz Oct 2 '11 at 18:07
    
xautolock locks the screen, yes, but I need to lock the screen when I press a button. I already figured it out, but thanks for the suggestions ;) –  Blender Oct 2 '11 at 20:01
add comment

This is not pretty, but working solution for unlock kde or lightdm session from screensaver via cli (command line):

qdbus | grep kscreenlocker_greet | xargs -I {} qdbus {} /MainApplication quit
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.