I use pam_usb and want to lock/unlock computer when USB stick is removed/inserted. For locking I use qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock
and it works perfectly. For unlocking I've tried a series of commands I've found (most of them are aggregated here), but they don't work. Specifically, if we exclude those with KDE 4 syntax, they fall into 2 categories: those using qdbus (relevant path here, several variations exists) /MainApplication quit
which hang my Xorg completely, and those using killall
against screenlocker process, but the process just restarts instantly after that!
So, my question is: how to unlock KDE5 screen locked with its standard locker programmatically?
qdbus org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.Lock
does activate the screensaver in "locked" mode {you can replace the last fragment withorg.freedesktop.ScreenSaver.SetActive
true
to put up the saver without a lock} and in either case you may get the screen back with that latter withfalse
- but the monitor (not the whole screen as I have two monitor in one virtual...kill `ps ax | grep "kscreenlocker" | grep -v grep | cut -d" " -f 1`
is not going to be much help to you though it works in my particular case...qdbus org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.SetActive false
doesn't unlock screen on my Arch Linux with KDE PLasma 5.6.1... org.freedesktop.SetActive true
(i.e. in "saver" mode) rather than via... org.freedesktop.Lock
(i.e. in "lock" mode). That is why I had to resort to usingkill
on anykscreenlocker
processes running under my UID. kscreenlocker is what runs the selected screensaver(s) at least in my setup, however YMMV.