![]() Registered Member ![]()
|
Hello,
I've been trying to run a script right when KDE is locked and succeeded, now I'm trying to run another script (that basically "undoes" what the first script does) each time the environment is unlocked. First, the "lock" script. I'm using a really ugly method, so I'd like to know if there's a more elegant way to do it. If not, that's fine, I'm mentioning it here just in case: I moved /usr/lib/kde4/libexec/krunner_lock to /usr/lib/kde4/libexec/krunner_lock_bin, then created a shell script at /usr/lib/kde4/libexec/krunner_lock and put the script I wanted to execute, followed by a call to /usr/lib/kde4/libexec/krunner_lock_bin. It's ugly but it works :undecided: I'd like to execute another script whenever the workspace is unlocked. I don't mind if it's hackish (can't get more hackish than the method above). I tried using the Autostart thing in the System settings, but you can only set scripts to start on system/session startup, not session unlock. (Should I have posted this in the "Users" forum rather than the "Developers" one? :-O) Edit: While you could have guessed looking at the path I mentioned (/usr/lib/kde4/...), I'm using KDE 4. I guess it's important to mention that. Kubuntu 9.04 64-bit to be more precise.
Last edited by WindPower on Mon Jun 01, 2009 4:44 pm, edited 1 time in total.
|
![]() KDE Developer ![]()
|
Can't you put the second script after you call krunner_lock_bin?
Cheers, _
anda_skoa, proud to be a member of KDE forums since 2008-Oct.
|
![]() Registered Member ![]()
|
No, because that gets executed whenever the mouse is moved while the screensaver is running, not when the session is unlocked. I found a way to do it: http://live.gnome.org/GnomeScreensaver/ ... 8bb9b33043 But... It's for Gnome ![]() Edit: Also found this, which I could adapt to my needs: http://trac.gajim.org/wiki/KDesktopLock But... KDE 3 ![]()
Last edited by WindPower on Mon Jun 01, 2009 4:43 pm, edited 1 time in total.
|
![]() Registered Member ![]()
|
Solved! Basically, krunner_lock is called with the argument --forcelock when the session gets locked. If this argument is not present, the session unlocks without password whenever the mouse is moved (which is why krunner_lock_bin exited right when the mouse moved). My bash script, which replaced krunner_lock, didn't pass its own arguments to krunner_lock_bin, but now it does and the whole thing works.
For those of you who want to do something similar, here's the code:
![]()
Last edited by WindPower on Sat May 30, 2009 5:11 pm, edited 1 time in total.
|
![]() Registered Member ![]()
|
Hi,
I'm running Kubuntu 9.10 and can't find /usr/lib/kde4/libexec/krunner_lock or any krunner_lock. Have you managed to adapt the script to the new Kubuntu/KDE version? |
![]() Registered Member ![]()
|
Yes, it's here now: /usr/lib/kde4/libexec/kscreenlocker |
![]() Registered Member ![]()
|
Thanks. I guess I didn't search hard enough.
![]() |
![]() Registered Member ![]()
|
While I'm at it, would you know how to do the following things through the script?:
-mark xchat as away/back -mark skype as away/back -pause/resume or change speeds in ktorrent (or other torrent client) -pause/resume amarok I'm also interested in any other interesting ideas you may have. ![]() My current script:
![]() |
![]() Registered Member ![]()
|
I wouldn't know for XChat as I don't use it. Most of these programs should have a D-Bus interface, so it should be possible.
For Pidgin, you can use the purple-remote utility (it's a wrapper around its D-BUS interface) For Skype, you can either use Pidgin with the skype4pidgin plugin and set your status from Pidgin, or you can use the Skype API which is apparently available via D-BUS on the Linux version of Skype: https://developer.skype.com/Docs/ApiDoc ... I_on_Linux For XChat: http://blogs.gnome.org/ovitters/2005/11 ... and-xchat/ For KTorrent: http://www.kvirc.de/docu/fnc_system.dbus.html has some example for stopping KTorrent's downloads, or you can use KTorrent's scripting interface: http://ktorrent.org/wiki/index.php/Writing_Scripts For Amarok, I'm sure it has a D-BUS interface too but you can use amarok with command-line arguments to get what you want: http://docs.kde.org/development/en/extr ... tions.html |
![]() Registered Member ![]()
|
It's possible to go a long way with D-Bus... Here's some of the stuff I have in my lock script:
And unlock:
Note: I am saving the mute status in a file rather than a script variable because my locking and unlocking scripts are two separate files; if you do all the scripting in /usr/lib/kde4/libexec/kscreenlocker, you can use variables just fine. |
![]() Registered Member ![]()
|
Now it's June-2012 and on Kubuntu 12.04 I'm using the following script:
run it from the command line - if You are not sure what it is doing. |
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft