Package: wmsun Version: 1.03-25 Severity: normal Tags: patch Hi,
following up to bug #440406, I would like to propose an enhanced fix for even longer sleep cycles, which I had implemented for wmnd in a similar fashion a few months ago. Instead of sleeping for a fixed interval, one may call select on the file descriptor of the X display, timing out after the delay interval. If a display event occurs during the select call, the display will be redrawn immediately; otherwise, program execution blocks for the given delay interval. Consequently, a longer sleep interval can be chosen (e.g. 1 sec), without hurting responsiveness of the program. This seems to be a perfect solution for saving power while running on a laptop battery. Regards, Peter -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'stable'), (400, 'testing'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 2.6.23-maia Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages wmsun depends on: ii libc6 2.6.1-5 GNU C Library: Shared libraries ii libx11-6 2:1.0.3-7 X11 client-side library ii libxext6 1:1.0.3-2 X11 miscellaneous extension librar ii libxpm4 1:3.5.7-1 X11 pixmap library wmsun recommends no packages. -- debconf information: * wmsun/latitude: 48.15 * wmsun/longitude: 11.5833333
--- wmsun-1.03.orig/wmSun/wmSun.c +++ wmsun-1.03/wmSun/wmSun.c @@ -86,7 +86,7 @@ /* * Delay between refreshes (in microseconds) */ -#define DELAY 100000L +#define DELAY 1000000L #define WMSUN_VERSION "1.03" #define DegPerRad 57.29577951308232087680 @@ -132,6 +132,8 @@ long CurrentLocalTime, CurrentGMTTime, date; double UT, val, LTRise, LTSet, LocalHour, hour24(); int H, M; + struct timeval timeout; + fd_set xfdset; @@ -266,6 +268,11 @@ + /* + * Add X display to file descriptor set for polling. + */ + FD_ZERO(&xfdset); + FD_SET(ConnectionNumber(display), &xfdset); @@ -296,7 +303,9 @@ * Redraw and wait for next update */ RedrawWindow(); - usleep(DELAY); + timeout.tv_sec = DELAY / 1000000L; + timeout.tv_usec = DELAY % 1000000L; + select(ConnectionNumber(display) + 1, &xfdset, NULL, NULL, &timeout); }