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

Lock all sessions with bash script?

Tags: None
(comma "," separated)
KarlisRepsons
Registered Member
Posts
42
Karma
0

Lock all sessions with bash script?

Wed Dec 03, 2008 9:01 pm
Is that possible? Say, lock all the opened sessions?

Last edited by KarlisRepsons on Fri Jul 30, 2010 6:31 pm, edited 2 times in total.


KarlisRepsons, proud to be a member of KDE forums since 2008-Nov.
User avatar
sayakb
Administrator
Posts
1973
Karma
12
OS

RE: Lock session with bash script?

Wed Dec 03, 2008 9:50 pm
You can use this script to lock the screen:
Code: Select all
qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock


KarlisRepsons
Registered Member
Posts
42
Karma
0

RE: Lock session with bash script?

Thu Dec 04, 2008 9:19 am
There is no qdbus in my PATH... What is it?


KarlisRepsons, proud to be a member of KDE forums since 2008-Nov.
User avatar
msoeken
Mentor
Posts
300
Karma
4
OS

RE: Lock session with bash script?

Thu Dec 04, 2008 9:21 am
Which KDE version are you using? qdbus should be available for KDE 4.


Image
[size=x-small]code | [url=cia.vc/stats/author/msoeken]cia.vc[/url] | [url=kde.org/support]donating KDE[/url] | [url=tinyurl.com/cto4ns]wishlist[/url][/size]
KarlisRepsons
Registered Member
Posts
42
Karma
0

RE: Lock session with bash script?

Thu Dec 04, 2008 9:25 am
So it's clear about 3.5..?


KarlisRepsons, proud to be a member of KDE forums since 2008-Nov.
User avatar
msoeken
Mentor
Posts
300
Karma
4
OS

RE: Lock session with bash script?

Thu Dec 04, 2008 9:47 am
Then try
Code: Select all
dcop kdesktop KScreensaverIface lock


Image
[size=x-small]code | [url=cia.vc/stats/author/msoeken]cia.vc[/url] | [url=kde.org/support]donating KDE[/url] | [url=tinyurl.com/cto4ns]wishlist[/url][/size]
KarlisRepsons
Registered Member
Posts
42
Karma
0

RE: Lock session with bash script?

Thu Dec 04, 2008 9:49 am
Nice. Thank you.


KarlisRepsons, proud to be a member of KDE forums since 2008-Nov.
User avatar
sayakb
Administrator
Posts
1973
Karma
12
OS

RE: Lock session with bash script?

Sat Dec 06, 2008 5:51 am
If your problem is solved, please add a [solved] tag to the thread title.


KarlisRepsons
Registered Member
Posts
42
Karma
0

RE: Lock session with bash script?

Sun Dec 07, 2008 4:27 pm
LinuxIsInnovation wrote:If your problem is solved, please add a [solved] tag to the thread title.


I think, yes. I have to lock session of each user separately, but is fine as for me.


KarlisRepsons, proud to be a member of KDE forums since 2008-Nov.
KarlisRepsons
Registered Member
Posts
42
Karma
0
.. but not really.
On another machine I try that with
sudo -H -u target_user dcop kdesktop KScreensaverIface lock
and it says, it can't attach to DCOP server.

Andother way
dcop --all-users --all-sessions kdesktop KScreensaverIface lock
fails too and complains, that "DCOPClient::attachInternal. Attach failed Could not open network socket" ant then again about attaching.

:(
This is bad. I am sure, firewall is not to blame there. Is 3.5.7 KDE. Please, I don't want to upgrade, can I solve it there?


KarlisRepsons, proud to be a member of KDE forums since 2008-Nov.
User avatar
sayakb
Administrator
Posts
1973
Karma
12
OS
Do you have xscreensaver activated?
Try this:
Code: Select all
xscreensaver-command -lock


KarlisRepsons
Registered Member
Posts
42
Karma
0
It could be: no.
No "xscreensaver-command" to execute...


KarlisRepsons, proud to be a member of KDE forums since 2008-Nov.
KarlisRepsons
Registered Member
Posts
42
Karma
0
Time flies...
Now it's kde4 and the same question, a bit changed like this: "how to lock all KDE sessions from acpi shell script"?


KarlisRepsons, proud to be a member of KDE forums since 2008-Nov.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
You need to get a list of all logged in users, then run the following command as them. The appropriate D-Bus session bus should be found automatically.

Code: Select all
qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
KarlisRepsons
Registered Member
Posts
42
Karma
0
Well I call this from my konsole:

Code: Select all
get_login_users() {
  who -u | egrep -o "^[^ ]*" | sort | uniq
}

do_lock() {
  for u in $(get_login_users)
  do
    sudo -u $u /usr/bin/qdbus org.kde.screensaver /ScreenSaver Lock
  done
}

do_lock


.. and it works, but I call it from vt2 and it complains about inability to connect to X11! What to do? I intended to use from an acpi script so...


KarlisRepsons, proud to be a member of KDE forums since 2008-Nov.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]