GNOME Bugzilla – Bug 313016
gnome-screensaver integration
Last modified: 2006-02-24 22:11:36 UTC
I believe gnome-screensaver (which'll probably be default in 2.14, I hope) sends a dbus message roughly equivalent to 'I'm away from the computer.' It would be nice if xchat-gnome listened to that and marked me away when gnome-screensaver triggered.
Gaim already monitors X usage and sends automatic away/back message based on that information. Screensaver integration would be nice.
Perhaps this could be done as a plugin first?
Funny thing that I found this bug :-) I wrote a plugin today that handles this stuff and goes away/comes back automatically depending on idleness (as reported by xscreensaver). It's fairly complete, and fetches idle data the same way as Gaim does, but fallbacks on xchat usage if xscreensaver isn't available. It also has some configuration as to when to get back from away and if nickname should change. If it is of interest, I could release it (as beta, since it hasn't been tested that much yet) for inclusion in xchat-gnome.
Absolutely!
Created attachment 53997 [details] autoaway plugin + buildsystem patch Attached tarball contains the autoaway plugin (extract it to xchat-gnome-0.6/plugins) and a patch to incorporate it into xchat-gnome's build system. The patch is against version 0.6. To use xscreensavers idle time reporting, you need the "X11 Screen Saver extension" installed, including development files. On ubuntu, this is package "libxss" and "libxss-dev". What it does: * Goes away after a configurable amount of idle time. - Comes back when user isn't idle anymore. * Goes away when screensaver kicks in. - Comes back when screensaver exits. * Force goaway using /GOAWAY command. - Needs manual /COMEBACK command to come back. * Change nickname when going away (for instance nick|away) and restore it when coming back. All configuration is done in gconf, "apps/xchat/plugins/autoaway", and the included schema should explain the keys. Issues: * I'm probably abusing the xchat_(get|set)_context() functions. Mostly because I don't fully understand them :-) * The fallback idle counter only updates when the user sends a message, could be improved to update also when switching tabs or doing something else within xchat. * I use polling, which is ugly, but currently the only working solution right now. * No support for gnome-screensavers DBus messages yet. Will add this as soon as it gnome-screensaver is included in Ubuntu :-) * It doesn't authenticate with NickServ when changing nick.
| * No support for gnome-screensavers DBus messages yet. Will add this as soon | as it gnome-screensaver is included in Ubuntu :-) Does universe count? :) http://mirrors.xmission.com/ubuntu/pool/universe/g/gnome-screensaver/
> Does universe count? :) Heh, of course it does. I've implemented dbus support now, but the idle time reporting of gnome-screensaver doesn't work here for some reason so my plugin is only semi functional with gnome-screensaver instead of xscreensaver.[1] I'll have to see how it works after I've rebooted the computer tonight - if idle time reporting starts to magically work, I'll submit a new version tomorrow. [1] You can try to see if it works for you by running: sleep 5 && dbus-send --session --print-reply --dest=org.gnome.screensaver --type=method_call /org/gnome/screensaver org.gnome.screensaver.getIdleTime and then not touch the computer until it returns. It should return 5 if all goes well
A few comments: - You don't need xg-plugin.h or the xg plugin handle if you're not using any of the functions in xg-plugin.h (which you're not) - glib provides macros for debug messages, so you don't need to define trace() - What is the purpose of /goaway and /comeback? - Why are you handling changing nick yourself? (note that this isn't something that xchat-gnome exposes to the user in UI anyway, since changing nickname on away is a Bad Thing[tm]). Shouldn't the /away bit change the nickname if xchat is set up that way? - There's an awful lot of configurability here. Even if it's just exposed in gconf, it makes for pretty complex code to have away/return triggers set up the way you did. Is it possible to just define away as idle and returned as not idle and use whatever method is best? That's all I can see for now, but I didn't read through it too carefully.
Hey David, thanks for the comments! Reply to the comments: - xg-plugin.h and all references to it has been removed! - while glibs debugging facilities are great, I think setting up a log-handler is a bit too much for this little plugin. Also, a define will completely remove all trace()-code from the binary when compiled w/o DEBUG enabled which it should be by everyone but me I guess :-) - regarding nick change: Heh, I didn't know changing nick upon away was a Bad Thing. I've just seen people do that, and figured it was something people wanted :-) I'll be happy to remove it. BTW, does XChat[-gnome] have a setting for this hidden in GConf? If so, then there's definetely no reason to keep it in autoaway! - /comeback and /goaway was there to enable nick change in a consistent manner, should go if nick-change-when-going-away gets removed! - I totally agree with you about the complexity. I've done a great deal of logic cleanup when I added DBus support, so it shouldn't be that bad now. If we (you actually) decide that a more simple route is to be taken w.r.t. when to go away/come back, this plugin could be simplified even more - and that is always a Good Thing[tm]... Perhaps just say "Away when screensaver is on - come back when it's not on anymore!". This gives the user a single place to configure an idle time - the screensaver configuration! Anyway, please take a look at v0.2 of autoaway and give me comments/suggestions for improvements!
Created attachment 54121 [details] [review] autoaway plugin v2 + buildsystem patch New version, includes support for gnome-screensaver using DBus communication. Buildsystem patch is the same as previous tarball, but it's included in this tarball nontheless. Notes: * DBus will only be used if --disable-dbus isn't called. There is no way to disable the dbus-plugin while still using dbus in autoaway. * Major code cleanups. More of a state-machine type of code path. * The type of screensaver check is now done at runtime, and check is in the following order: 1) gnome-screensaver using DBus (needs USE_DBUS defined) 2) xscreensaver using xss (needs USE_SCREENSAVER defined) 3) xchat idle time (always works) * the xchat idle time is updated when switching tabs or sending a message.(This should perhaps be in the plugin api and kept within xchat.) * Still lots of configuration in gconf that increases complexity :-| By the way, I filed bug #320223 against gnome-screensaver wrt the idle time reporting failure.
Looking better. As far as the nickname change thing, it looks like I was wrong about core support. Here's my argument anyways :). Most IRC channels frown on noise like auto-away messages, and I've seen a lot of new users get snapped at just because their client did something for them. This is mitigated a bit by the fact that we don't (yet) have plugin config in the prefs window, but still an issue. In addition, since you're using the xchat command stuff, it should be possible to have this in a separate plugin if someone wants it. I'm a big fan of lots of simple plugins which each do one thing, rather than a few highly complex ones. Other than that, it looks pretty good. I'd like to find a way to just intelligently handle the other two prefs (come-back trigger and max idle), but I can't think of anything right now. There's some whitespace-style issues that I'll fix if we decide to put this in xchat-gnome svn (is that your intention?), but that's the most trivial of things. xscreensaver.[hc] and gscreensaver.[hc] need copyright headers. Thanks for the hard work on this!
I've been using the plugin now since I wrote it, and the more I think of it, the more I think that autoaway should just go away when the screensaver kicks in[1] and come back when it exits. This will remove come-back trigger and max idle while still doing what its supposed to do. And I also agree with you on the nick change thing. I never use it and it's trivial to create a new plugin that takes care of it. I'm also a fan of the do-one-thing-and-do-it-well philosophy. And yeah, my intention is that this plugin gets accepted into the official tree. I will post a new version of autoaway later. I think i can even make it completely configuration free without mayor trade-offs... By the way, what's the problem with the whitespaces? From what I can tell from other source files in xchat-gnome, I'm using something very similar to you. Anyway, as you say - this is a minor issue :-) [1] Or use some other fancy global desktop presence notification service when it's available.
Isak: FWIW, I'm building x-g from svn again, so I'm willing to test any new patch you might have...
Created attachment 54697 [details] autoaway plugin v3 + buildsystem patch This is the latest version which I've been using now for some time. Note that this includes a new patch against the build system that should be applied to stock 0.6 sources (haven't tried SVN, but it might apply to that too). This version no longer depend on xss and works against both xscreensaver and gnome-screensaver. The screensaver detection is done at runtime. No configuration is needed as this version will go away with screensaver and come back when it exits. (i.e. No idle time tracking at all within the plugin) Note: Technically, I haven't tested this version against X11 screensaver, but the relevant code is the same as in earlier versions. It's just codepaths that have changed.
Committed to SVN - thanks!!
Hello. Good news, bad news. Good: We have an even spiffier API for you to use to detect idleness even when you have the screensaver disabled (the SessionIdleChanged signal). Bad: The DBUS interface name has changed to be consistent with the de-facto standard style. Details here: http://cvs.gnome.org/viewcvs/gnome-screensaver/doc/DBUS-API.txt?view=markup
Created attachment 60072 [details] [review] Patch for new dbus gnome-screensaver object This little patch should get xchat-gnome working again with gnome-screensaver. I've tested it on my system and it works fine.
Applied to svn, thanks!