idle detection
Sean Egan
seanegan at gmail.com
Thu Jul 26 15:18:14 EDT 2007
On 7/26/07, Ethan Blanton <elb at pidgin.im> wrote:
> What are the screensavers doing
> these days? Do they rely on display capture?
Comments in gtkidle.c led me to
http://bugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=271639 in which
Luke appears to foolishly argue with jwz about the best way to handle
this. jwz makes reference to
http://www.google.com/codesearch?hl=en&q=+xscreensaver-command+show:6YCRwMaw3Ss:RFRcZxe98D8:t-Na2BO0Uug&sa=N&cd=2&ct=rc&cs_p=http://familiar.handhelds.org/source/v0.8.0/package-sources/xscreensaver-4.16.tar.gz&cs_f=xscreensaver-4.16/driver/xscreensaver-command.c#a0
It looks like both of these techniques are dependent on xscreensaver
running; at least when I try xscreensaver-command -time I get
"xscreensaver-command: no screensaver is running on display :0.0"
In either case, it seems just like more polling;
http://live.gnome.org/GnomeScreensaver/FrequentlyAskedQuestions says:
Is there a way to perform actions when the screensaver activates or
deactivates? Or when the session becomes idle?
One way is to watch for the D-Bus signals from gnome-screensaver.
Here's an example of how to perform actions when the session becomes
idle or is no longer idle:
my $cmd = "dbus-monitor --session
\"type='signal',interface='org.gnome.ScreenSaver',member='SessionIdleChanged'\"";
open (IN, "$cmd |");
while (<IN>) {
if (m/^\s+boolean true/) {
print "*** Session is idle ***\n";
} elsif (m/^\s+boolean false/) {
print "*** Session is no longer idle ***\n";
}
}
which looks like a promising route, albeit specific to
'gnome-screensaver', which I didn't even realize existed.
Is it possible to, say, listen to events on the root window or something?
I think I'll do the above described for 2.1.0---poll with the
frequency set in preferences when not idle, and once every second or
two when idle (if people got by with polling for 7 years, they can
handle 3 more weeks), and then we can take care of this issue for real
in a subsequant release.
I suspect there's no good way to do this other than the special-case
hack for gnome-screensaver, though.
-s.
More information about the Devel
mailing list