Re: GtkICQ suggestion
- From: Daniel Burrows <Daniel_Burrows brown edu>
- To: gnome-list gnome org
- Subject: Re: GtkICQ suggestion
- Date: Wed, 27 Jan 1999 16:51:33 -0500
On Wed, Jan 27, 1999 at 04:36:54PM -0500, Daniel Burrows was heard to say:
> It would be nice if GtkICQ could automatically set the user's away state when
> the screensaver is activated. I recently implemented this in a friend's
> AIM client pretty simply; I created a callback routine which ran a selected
> program periodically (eg, every 10 seconds) and used the return value to check
> whether a screen saver was running. For xscreensaver, the program needed
> (although it could be tweaked to deal better with the case where xscreensaver
> isn't running) was:
> -----------
> #!/bin/sh
> xscreensaver-command -time | grep non-blank > /dev/null 2>& 1
> -----------
> I found a function in autoaway.c that seems to do something similar, but it's
> based on checking how long the display has been idle, if I understand it
> correctly. I have a very crude patch attached to this message which makes it
> execute the file /usr/local/bin/test-xscreensaver instead and go idle or return based on the reesult of that call. There are a bunch of problems with it but
> hopefully it at least demonstrates what I was thinking of.
> Maybe letting the user choose which method to use would work?
>
Oops. I didn't attach the patch to the message.
--
Daniel Burrows
Nothing is hopeless.
PROOF:
(a) Assume the opposite.
(b) If something _is_ hopeless, then its condition can only improve.
(c) If its condition can only improve, then there must be hope for it.
(d) Therefore, nothing is hopeless. QED.
Index: autoaway.c
===================================================================
RCS file: /cvs/gnome/gtkicq/src/autoaway.c,v
retrieving revision 1.2
diff -u -r1.2 autoaway.c
--- autoaway.c 1998/12/21 22:18:49 1.2
+++ autoaway.c 1999/01/27 21:51:18
@@ -1,7 +1,9 @@
#include "gtkicq.h"
#include "gtkfunc.h"
+#include <sys/types.h>
+#include <sys/wait.h>
-#ifdef USE_XSCREENSAVER
+#ifndef USE_XSCREENSAVER
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/scrnsaver.h>
@@ -34,6 +36,42 @@
icq_change_status( data->sok, STATUS_NA, data );
else if( time_idle > 60000 * AUTO_AWAY )
icq_change_status( data->sok, STATUS_AWAY, data );
+}
+
+#else
+
+char *script_name="/usr/local/bin/test-xscreensaver";
+
+void auto_away( struct sokandlb *data)
+
+{
+ int pid;
+ int result;
+ switch(pid=fork())
+ {
+ case -1: /* Ouch! error.. */
+ perror("gtkicq: cannot fork() for idle poll");
+ break;
+ case 0:
+ execl(script_name,script_name,NULL);
+ perror("gtkicq: cannot execl() idle poll");
+ break;
+ default:
+ waitpid(pid,&result,0);
+ if( WIFEXITED(result))
+ {
+ if(WEXITSTATUS(result))
+ {
+ printf("auto_away(): going away\n");
+ icq_change_status(data->sok,STATUS_AWAY,data);
+ }
+ else
+ {
+ printf("auto_away(): coming back\n");
+ icq_change_status(data->sok,STATUS_ONLINE,data);
+ }
+ }
+ }
}
#endif
PGP signature
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]