Package: tpb
Version: 0.6.3-2
Severity: wishlist
Tags: patch

Hi, here's a patch that adds a 'lightnotify' option that toggles the
displaying of the OSD message when the thinklight is toggled. This is
because some programs make use of the light by blinking it and the xosd
messages are annoying in that case.

-Josh

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.12
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL 
set to en_US.UTF-8)

Versions of packages tpb depends on:
ii  debconf                   1.4.52         Debian configuration management sy
ii  libc6                     2.3.2.ds1-22   GNU C Library: Shared libraries an
ii  libice6                   6.8.2.dfsg.1-2 Inter-Client Exchange library
ii  libsm6                    6.8.2.dfsg.1-2 X Window System Session Management
ii  libx11-6                  6.8.2.dfsg.1-2 X Window System protocol client li
ii  libxext6                  6.8.2.dfsg.1-2 X Window System miscellaneous exte
ii  libxosd2                  2.2.14-1.2     X On-Screen Display library - runt
ii  makedev                   2.3.1-78       creates device files in /dev
ii  xlibs                     6.8.2.dfsg.1-2 X Window System client libraries m

tpb recommends no packages.

-- debconf information excluded
diff -ur old/tpb-0.6.3/src/cfg.c tpb-0.6.3/src/cfg.c
--- old/tpb-0.6.3/src/cfg.c	2004-08-18 16:57:32.000000000 +0300
+++ tpb-0.6.3/src/cfg.c	2005-07-15 09:10:50.000000000 +0300
@@ -311,6 +311,9 @@
   /* cfg->xevents */
   cfg->xevents = DEFAULT_XEVENTS;
 
+  /* cfg->lightnotify */
+  cfg->lightnotify = DEFAULT_LIGHTNOTIFY;
+
   /* cfg->nvram */
   if(cfg->nvram != NULL) {
     free(cfg->nvram);
@@ -525,6 +528,9 @@
   /* cfg->callback */
   cfg->callback = NULL;
 
+  /* cfg->lightnotify */
+  cfg->lightnotify = UNDEFINED;
+  
   /* cfg->mixer */
   cfg->mixer = UNDEFINED;
 
@@ -688,6 +694,11 @@
     slave->powermgt = master->powermgt;
   }
 
+  /* cfg->lightnotify */
+  if(master->lightnotify != UNDEFINED) {
+    slave->lightnotify = master->lightnotify;
+  }
+
   /* cfg->xevents */
   if(master->xevents != UNDEFINED) {
     slave->xevents = master->xevents;
@@ -1127,6 +1138,22 @@
     }
   } /* }}} */
 
+  else if (strcmp(CFG_LIGHTNOTIFY, key) == 0) { /* {{{ */
+    int i = 0;
+    while(arg[i] != '\0') {
+      arg[i] = tolower(arg[i]);
+      i++;
+    }
+    if (strcmp(CFG_LIGHTNOTIFY_ON, arg) == 0)
+      cfg->lightnotify = STATE_ON;
+    else if (strcmp(CFG_LIGHTNOTIFY_OFF, arg) == 0)
+      cfg->lightnotify = STATE_OFF;
+    else {
+      fprintf(stderr, _("Illegal light notification state: %s\n"), arg);
+      _exit(1);
+    }
+  } /* }}} */
+
   else if (strcmp(CFG_MIXERSTEPS, key) == 0) { /* {{{ */
     cfg->mixersteps = (int)strtol(arg, &endptr, 10);
     if(strlen(endptr) > 0 || cfg->mixersteps < 0) {
diff -ur old/tpb-0.6.3/src/cfg.h tpb-0.6.3/src/cfg.h
--- old/tpb-0.6.3/src/cfg.h	2004-08-18 17:00:53.000000000 +0300
+++ tpb-0.6.3/src/cfg.h	2005-07-15 08:58:32.000000000 +0300
@@ -40,6 +40,7 @@
 #define DEFAULT_POLLTIME 200000
 #define DEFAULT_NVRAMDEV "/dev/nvram"
 #define DEFAULT_NVRAMDEV_DEVFS "/dev/misc/nvram"
+#define DEFAULT_LIGHTNOTIFY STATE_OFF
 #define DEFAULT_MIXER STATE_OFF
 #define DEFAULT_MIXERSTEPS 14
 #define DEFAULT_MIXERDEV "/dev/mixer"
@@ -82,6 +83,9 @@
 #define CFG_XEVENTS "xevents"
 #define CFG_XEVENTS_ON "on"
 #define CFG_XEVENTS_OFF "off"
+#define CFG_LIGHTNOTIFY "lightnotify"
+#define CFG_LIGHTNOTIFY_ON "on"
+#define CFG_LIGHTNOTIFY_OFF "off"
 #define CFG_NVRAM "nvram"
 #define CFG_POLLTIME "polltime"
 #define CFG_THINKPAD "thinkpad"
@@ -134,6 +138,7 @@
   int apm;
   int powermgt;
   int xevents;
+  int lightnotify;
   char *nvram;
   int polltime;
   char *tpb_cmd;
diff -ur old/tpb-0.6.3/src/tpb.c tpb-0.6.3/src/tpb.c
--- old/tpb-0.6.3/src/tpb.c	2004-08-22 16:45:11.000000000 +0300
+++ tpb-0.6.3/src/tpb.c	2005-07-15 09:11:00.000000000 +0300
@@ -442,7 +442,7 @@
 	}
       }
 #ifdef HAVE_LIBXOSD
-      if(osd_ptr != NULL) {
+      if(osd_ptr != NULL && cfg.lightnotify == STATE_ON) {
 	xosd_display(osd_ptr, 0, XOSD_string, thinkpad_state.thinklight_toggle == 1 ? _("ThinkLight on") : _("ThinkLight off"));
 	xosd_display(osd_ptr, 1, XOSD_string, "");
       }

Reply via email to