View previous topic :: View next topic |
Author |
Message |
cz0 Apprentice
Joined: 13 Jun 2005 Posts: 280 Location: /earth/russia/moscow
|
Posted: Thu Jan 13, 2022 9:52 pm Post subject: Lock all active KDE/Plasma sessions using CLI and DBUS |
|
|
Hi, folks!
I'm using a sophisticated algorithm to perform actions depending on ACPI events on my laptop. Therefor I'm forced to lock my KDE/Plasma sessions from CLI.
Previously I used this bash code to lock sessions:
Code: |
for SESSION in $(qdbus --literal --system org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.GetSessions | sed 's/^.*\(Session[0-9]*\).*$/\1/'); do
dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/$SESSION org.freedesktop.ConsoleKit.Session.Lock
done
|
This script is executed by acpid (by root) and not related to any actual user session.
But some time ago ConsoleKit was deprecated and not available via DBus anymore.
I found that:
Code: |
dbus-send --session --dest=org.freedesktop.ScreenSaver --type=method_call /org/freedesktop/ScreenSaver org.freedesktop.ScreenSaver.Lock
|
executed from an actual user will lock the active session, but will not work if executed from root.
Any ideas hot to make it work if executed by acpid to lock all active KDE/Plasma sessions? |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9689 Location: almost Mile High in the USA
|
Posted: Thu Jan 13, 2022 10:48 pm Post subject: |
|
|
find out who's logged in on console
su to that user and find dbus socket
run script
profit
? _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
cz0 Apprentice
Joined: 13 Jun 2005 Posts: 280 Location: /earth/russia/moscow
|
Posted: Sat Jan 15, 2022 5:11 pm Post subject: |
|
|
This suppose to work using dbus only, just like it use to. |
|
Back to top |
|
|
|