Score one for open source project docs
June 20th, 2007 | Published in open source | 9 Comments
For once I am impressed by the level of documentation available for both GNOME Screensaver and Pidgin.
I’ve been using Sametime lately in Windows and like the fact that it sets my status to away when the screen is locked. The open source community has been talking about doing it for years with Pidgin, but I couldn’t find an existing plugin that did it.
I was looking forward to working with DBus and the Pidgin plugin API when I came across the GNOME Screensaver docs and FAQ. Those two pages plus a faint memory of gaim-remote and voila:
my($cmd) = "dbus-monitor --session \"type='signal',interface='org.gnome.ScreenSaver',member='SessionIdleChanged'\"";
open (IN, "$cmd |");
while (<IN>) {
if (m/^\s+boolean true/) {
s y s t e m ("gaim-remote 'setstatus?status=away&message=Away'");
} elsif (m/^\s+boolean false/) {
s y s t e m("gaim-remote 'setstatus?status=available&message='");
}
}
Update: sorry for the spacing of some of the code, but it looks like there’s either a WordPress, PHP, or DreamHost issue with me putting in a particular Perl function call that also happens to be a PHP function.





July 20th, 2007 at 8:45 am (#)
Cool. I’m actually trying to achieve the exact opposite: invoke the screensaver when my pidgin status turns to away. Unfortunately purple-remote appears to be broken now. I’ve achieved it by setting a buddy pounce on myself.
November 1st, 2007 at 7:59 pm (#)
I’m interested in your script because when I close my laptop, Ubuntu (7.04) locks the screen. And it would be really handy for Pidgin to set me to “away” when that happens.
But my question is: How do I actually get this script to work?
November 1st, 2007 at 8:16 pm (#)
@cloud858rk: You can save that script and mark it executable (chmod +x scriptfilename). Then go to System -> Preferences -> Sessions and click Add on the Startup Programs tab. Enter in a name you’ll remember for the command and then browse for the script file.
GNOME (specifically gnome-session) will automatically start the script for you when you log in and it will run in the background listening for DBus events.
There were two downsides to that script. One, I had to hardcode the away message in the script, and two, I never really confirmed this but I think if you have already set an away message and the screensaver activates, it will be overwritten by whatever the script has saved.
November 1st, 2007 at 9:46 pm (#)
Thanks for you quick response, but I haven’t gotten it to work yet.
I’ve tried locking the screen by clicking the power icon (in the top right corner of the screen), waiting for my screensaver to activate, and shutting my laptop (not to be confused with shutting it off). I’ve tried this on Pidgin (2.2.2, the newest version) and Gaim (2.0.0 Beta 6, the one that installed with Ubuntu). I’ve tried all the combinations of these, but it still hasn’t worked.
The only instruction I had troubles with was “chmod +x scriptfilename”. I replaced “scriptfilename” with the exact path the script was at, and typed it into the terminal. The terminal didn’t not give an error message or any hint that the file had changed to an executable correctly.
Instead of using the chmod command, I tried going into the file’s properties (Right Click -> Properties), going under the “Permissions” tab, and under “Execute:” I checked in “Allow executing file as program”. But this still didn’t help any.
Do you know what I’m doing wrong?
November 2nd, 2007 at 8:52 am (#)
Two possibilities come to mind. First, you’ll want to make sure that the script is actually running in the background. The steps I told you earlier to add it to your session only take effect when you log out and back in (it won’t start it if you’re already logged in).
If you don’t want to log out, press Alt+F2 to open the run dialog, type in the full path to the script, and click Run to start it. You may want to verify it’s running by opening a terminal (Applications -> Accessories -> Terminal) and using ps or pgrep to verify it (e.g. “pgrep -l scriptname”).
The other thought I had is that the screensaver is not generating the DBus events for the actions you tried. You can verify it by opening a terminal and running the following command (and then activating the screensaver, locking it, etc.):
dbus-monitor –session “type=’signal’,interface=’org.gnome.ScreenSaver’,member=’SessionIdleChanged’”
It’s the same command that the script will run, but you’ll be able to see if the screensaver is sending the right events.
November 5th, 2007 at 8:36 pm (#)
I entered: dbus-monitor –session “type=’signal’,interface=’org.gnome.ScreenSaver’,member=’SessionIdleChanged’â€
Then I got the error message: Failed to setup match “–session”: Match rule has a key with no subsequent ‘=’ character
November 5th, 2007 at 10:24 pm (#)
My apologies. You need two hyphens for the session parameter (as in the original post).
November 7th, 2007 at 8:39 pm (#)
Failed to setup match ““type=’signal’,interface=’org.gnome.ScreenSaver’,member=’SessionIdleChanged’—: Unknown key ““type” in match rule
I don’t think we can get it to work anymore…
February 6th, 2008 at 3:12 pm (#)
I got it to work. I initially had the same errors as cloud858rk, but replacing all the fancy single and double quotes with normal single and double quotes in the command line fixed it.