[PATCH xf86-input-synaptics] syndaemon: decouple background mode from quietness

Alessandro ag at alessandroguido.name
Fri Dec 3 02:55:00 PST 2010


syndaemon currently outputs lots of stuff when not running in background mode.
However, current init daemons and session managers can manage to launch the
daemon in background without "-b" just fine (if not better), by doing the
fork() themselves. Indeed, if one uses that setup, ie. by having syndaemon
launched by GNOME at login, it gets the ~/.xsession-errors file spammed by
Enable/Disabled messages.

This patch fixes this by introducing a new verbose (-v) flag that enables those
messages and makes syndaemon quiet by default.

Signed-off-by: Alessandro Guido <ag at alessandroguido.name>
---
 tools/syndaemon.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/tools/syndaemon.c b/tools/syndaemon.c
index d06fe5f..addfe40 100644
--- a/tools/syndaemon.c
+++ b/tools/syndaemon.c
@@ -64,6 +64,7 @@ static XDevice *dev;
 static Atom touchpad_off_prop;
 static TouchpadState previous_state;
 static TouchpadState disable_state = TouchpadOff;
+static int verbose;
 
 #define KEYMAP_SIZE 32
 static unsigned char keyboard_mask[KEYMAP_SIZE];
@@ -82,6 +83,7 @@ usage(void)
     fprintf(stderr, "  -k Ignore modifier keys when monitoring keyboard activity.\n");
     fprintf(stderr, "  -K Like -k but also ignore Modifier+Key combos.\n");
     fprintf(stderr, "  -R Use the XRecord extension.\n");
+    fprintf(stderr, "  -v Print diagnostic messages.\n");
     exit(1);
 }
 
@@ -110,7 +112,7 @@ toggle_touchpad(Bool enable)
     if (pad_disabled && enable) {
         data = previous_state;
         pad_disabled = False;
-        if (!background)
+        if (verbose)
             printf("Enable\n");
     } else if (!pad_disabled && !enable &&
                previous_state != disable_state &&
@@ -118,7 +120,7 @@ toggle_touchpad(Bool enable)
         store_current_touchpad_state();
         pad_disabled = True;
         data = disable_state;
-        if (!background)
+        if (verbose)
             printf("Disable\n");
     } else
         return;
@@ -290,7 +292,7 @@ Bool check_xrecord(Display *display) {
 			    &first_error);
 
     status = XRecordQueryVersion(display, version, version+1);
-    if (!background && status) {
+    if (verbose && status) {
 	printf("X RECORD extension version %d.%d\n", version[0], version[1]);
     }
     return found;
@@ -433,7 +435,7 @@ void record_main_loop(Display* display, double idle_time) {
 
 	if (ret == 0 && pad_disabled) { /* timeout => enable event */
 	    toggle_touchpad(True);
-	    if (!background) printf("enable touchpad\n");
+	    if (verbose) printf("enable touchpad\n");
 	}
 
     } /* end while(1) */
@@ -543,6 +545,9 @@ main(int argc, char *argv[])
 	case 'R':
 	    use_xrecord = 1;
 	    break;
+	case 'v':
+	    verbose = 1;
+	    break;
 	default:
 	    usage();
 	    break;
-- 
1.7.3.2



More information about the xorg-devel mailing list