Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When I leave work, I lock my machine with ctrl + l to lock the screen. When I come back, I always forget to log into jabber. Is there a way to run a command after the screen is unlocked? This is in KDE. I'm not sure if the locking mechanism is an X feature or a KDE feature, so I'm not sure where to look.

share|improve this question
add comment

2 Answers 2

I had a desire to make banshee (the Gnome music player) pause/unpause when the screen was locked/unlocked. I found a ticket in the banshee launchpad project:

https://bugs.launchpad.net/banshee/+bug/237687

Someone had created a script which would notice (via DBus) if the screen was (un)locked and would trigger banshee to (un)pause. I added a small tweak to this script and have been using it for a while. I added my updated copy to that ticket.

Now I know this isn't exactly what you want to do. But you could probably take that python script (which is already detecting screen locks/unlocks) and alter it slightly to do what you would like to do. It is also my understanding that the KDE screensaver supports the same DBus interface as the gnome screensaver. It seems like the best documentation for the KDE side of things is here:

http://quickgit.kde.org/?p=kde-workspace.git&a=blob&f=krunner/screensaver/saverengine.h

Good luck!

share|improve this answer
    
So is the lock screen considered a screen saver? –  Falmarri Jul 11 '11 at 17:15
    
Yeah. I mean, I'm pretty sure they both produce the same event in DBus. –  Mark Drago Jul 11 '11 at 21:58
    
For KDE users, substitute "org.freedesktop.ScreenSaver" for the Gnome specific string on the second last line of the script. –  casualunixer Feb 9 '13 at 16:44
add comment

For the XScreenSaver the solution is xscreensaver-command -watch

man xscreensaver-command contains an example Perl script to handle various screensaver and screen lock events, like BLANK, LOCK, UNBLANK etc.

Here it is - the example turning sound off and on with the screensaver:

       #!/usr/bin/perl

       my $blanked = 0;
       open (IN, "xscreensaver-command -watch |");
       while (<IN>) {
           if (m/^(BLANK|LOCK)/) {
               if (!$blanked) {
                   system "sound-off";
                   $blanked = 1;
               }
           } elsif (m/^UNBLANK/) {
               system "sound-on";
               $blanked = 0;
           }
       }

Not sure if KDE uses XScreenSaver though.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.