This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Locking screen/session from command line?

Tags: None
(comma "," separated)
pparent
Registered Member
Posts
16
Karma
0
Hi,

Does anyone know how to send a command to lock screen/session?

Thank's!
airdrik
Registered Member
Posts
1854
Karma
5
OS
First you have to have access to the session's DBus session, then you would be able to issue:
qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock

Some more information/options are listed on this SO question


airdrik, proud to be a member of KDE forums since 2008-Dec.
pparent
Registered Member
Posts
16
Karma
0
Hi!

Thank's so much!

unfortunatly it does not seem to work on postmarketOS, having installed qt5-qttools:

From SSH:
Code: Select all
/usr/lib/qt5/bin/qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock
Could not connect to D-Bus server: org.freedesktop.DBus.Error.Spawn.ExecFailed: /usr/bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.


From direct console:
Code: Select all
/usr/lib/qt5/bin/qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock
Service 'org.freedesktop.ScreenSaver' does not exist.


Code: Select all
sudo /usr/lib/qt5/bin/qdbus  --system org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Session1  Lock
Error: org.freedesktop.DBus.Error.UnknownMethod
No such interface '(null)' on object at path /org/freedesktop/ConsoleKit/Session1


Any idea?

Thank's a lot!
pparent
Registered Member
Posts
16
Karma
0
If I try this command from user it says:

Code: Select all
/usr/lib/qt5/bin/qdbus  --system org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Session1  Lock
Error: org.freedesktop.DBus.Error.AccessDenied
Rejected send message, 4 matched rules; type="method_call", sender=":1.34" (uid=10000 pid=1800 comm="/usr/lib/qt5/bin/qdbus --system org.freedesktop.Co") interface="(unset)" member="Lock" error name="(unset)" requested_reply="0" destination="org.freedesktop.ConsoleKit" (uid=0 pid=1573 comm="/usr/sbin/console-kit-daemon --no-daemon ")


Sounds encouraging but how to get permissions?
pparent
Registered Member
Posts
16
Karma
0
After modifiying dbus permitions I get with normal user:

Code: Select all
/usr/lib/qt5/bin/qdbus  --system org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Session1  Lock
Error: org.freedesktop.DBus.Error.UnknownMethod
No such interface '(null)' on object at path /org/freedesktop/ConsoleKit/Session1


as well.
pparent
Registered Member
Posts
16
Karma
0
The following command almost does what I want:
/usr/lib/qt5/bin/qdbus --system org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Session1 org.freedesktop.ConsoleKit.Session.Lock


But not quite since it displays the login screen and respond to touches.
bshah
Registered Member
Posts
77
Karma
0
OS
pparent wrote:The following command almost does what I want:
/usr/lib/qt5/bin/qdbus --system org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Session1 org.freedesktop.ConsoleKit.Session.Lock


But not quite since it displays the login screen and respond to touches.


It is not login screen well, but lockscreen, and well. to unlock lockscreen you need to have some kind of input? That input is not passed to other windows but just lockscreen.
pparent
Registered Member
Posts
16
Karma
0
Ok.

The remaining issue is not about the lockscreen kde displays asking for pin code (it works well!).

The expected behavior is that backlight is off and touchscreen does not respond. That's exactly what happens when the phone idles for too long.
But this does not happen with this command: backlight is on and touchscreen responds.
airdrik
Registered Member
Posts
1854
Karma
5
OS
If I understand correctly, the next step is that you need to turn the screen off. A quick google yeilds: https://askubuntu.com/questions/189677/ ... ion-in-kde which suggests running "xset dpms force off". No guarantees if that will work with the phone, but I think it's worth a shot.


airdrik, proud to be a member of KDE forums since 2008-Dec.
pparent
Registered Member
Posts
16
Karma
0
Thank's but I get:

Code: Select all
server does not have extension for dpms option
xset:  unknown option force


Also xset is an X program where plasma-mobile is based on wayland...
pparent
Registered Member
Posts
16
Karma
0
kscreen-doctor -d off


Seems to allow to go one step further: it locks screen. But I still have to get luminosity down.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]