diff options
author | Florian Schäfer <florian.schaefer@gmail.com> | 2008-06-08 18:53:31 +0200 |
---|---|---|
committer | Christoph Brill <egore911@egore911.de> | 2008-06-08 22:14:20 +0200 |
commit | a3d4930699f6544794befe00e0ceb91d55b8b65f (patch) | |
tree | 8a178b76180d93c72df71079d55406e0536fde1b | |
parent | 6269fdaf3283ba4a8051858fc2b43fa102823e96 (diff) |
Add synaptics-0.14.6-poll-delay.patch from SuSEsuse-patches
syndaemon is a program that monitors keyboard activity and disables the
touchpad when the keyboard is being used. Syndaemon is commonly used on laptop
computers. Monitored with PowerTOP
(http://www.lesswatts.org/projects/powertop/), syndaemon causing 45 wakeups a
second because of a hardcoded 20 ms timer. This behavior significantly reduce
battery life. This patch introduces a commandline switch to modify the poll
delay.
Running e.g. "synadmon -m 500" uses a 500 ms timer instead of the hardcoded 20
ms one, makes syndaemon disappear from PowerTOP, while still doing a accurate
job. (bnc #386709)
-rw-r--r-- | src/syndaemon.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/syndaemon.c b/src/syndaemon.c index c72977a..4befb64 100644 --- a/src/syndaemon.c +++ b/src/syndaemon.c @@ -44,15 +44,17 @@ static const char *pid_file; #define KEYMAP_SIZE 32 static unsigned char keyboard_mask[KEYMAP_SIZE]; static void usage() { - fprintf(stderr, "Usage: syndaemon [-i idle-time] [-d] [-t] [-k]\n"); + fprintf(stderr, "Usage: syndaemon [-i idle-time] [-m poll-delay] [-d] [-t] [-k]\n"); fprintf(stderr, " -i How many seconds to wait after the last key press before\n"); fprintf(stderr, " enabling the touchpad. (default is 2.0s)\n"); + fprintf(stderr, " -m How many milli-seconds to wait until next poll.\n"); + fprintf(stderr, " (default is 20ms)\n"); fprintf(stderr, " -d Start as a daemon, ie in the background.\n"); fprintf(stderr, " -p Create a pid file with the specified name.\n"); fprintf(stderr, " -t Only disable tapping and scrolling, not mouse movements.\n"); fprintf(stderr, " -k Ignore modifier keys when monitoring keyboard activity.\n"); fprintf(stderr, " -K Like -k but also ignore Modifier+Key combos.\n"); exit(1); @@ -160,15 +162,14 @@ get_time() struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec + tv.tv_usec / 1000000.0; } static void -main_loop(Display *display, double idle_time) +main_loop(Display *display, double idle_time, int poll_delay) { - const int poll_delay = 20000; /* 20 ms */ double last_activity = 0.0; double current_time; pad_disabled = 0; keyboard_activity(display); @@ -229,23 +230,27 @@ setup_keyboard_mask(Display *display, int ignore_modifier_keys) } int main(int argc, char *argv[]) { double idle_time = 2.0; + int poll_delay = 20000; /* 20 ms */ Display *display; int c; int shmid; int ignore_modifier_keys = 0; /* Parse command line parameters */ - while ((c = getopt(argc, argv, "i:dtp:kK?")) != EOF) { + while ((c = getopt(argc, argv, "i:m:dtp:kK?")) != EOF) { switch(c) { case 'i': idle_time = atof(optarg); break; + case 'm': + poll_delay = atoi(optarg) * 1000; + break; case 'd': background = 1; break; case 't': disable_taps_only = 1; break; @@ -315,10 +320,10 @@ main(int argc, char *argv[]) } } setup_keyboard_mask(display, ignore_modifier_keys); /* Run the main loop */ - main_loop(display, idle_time); + main_loop(display, idle_time, poll_delay); return 0; } |