Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Lock all active KDE/Plasma sessions using CLI and DBUS
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
cz0
Apprentice
Apprentice


Joined: 13 Jun 2005
Posts: 280
Location: /earth/russia/moscow

PostPosted: Thu Jan 13, 2022 9:52 pm    Post subject: Lock all active KDE/Plasma sessions using CLI and DBUS Reply with quote

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
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 8593
Location: almost Mile High in the USA

PostPosted: Thu Jan 13, 2022 10:48 pm    Post subject: Reply with quote

find out who's logged in on console
su to that user and find dbus socket
run script
profit

?
_________________
Intel Core i7 2700K/RadeonHD 6450/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
cz0
Apprentice
Apprentice


Joined: 13 Jun 2005
Posts: 280
Location: /earth/russia/moscow

PostPosted: Sat Jan 15, 2022 5:11 pm    Post subject: Reply with quote

This suppose to work using dbus only, just like it use to.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum