Package: numlockx
Version: 1.2-4
Severity: normal
Tags: patch

Corrected and cleaned up /etc/X11/Xsession.d/55numlockx.
The distributed /etc/default/numlockx may also need a cleanup.

The approximate end result (filtered by reportbug) is shown bellow.
Attached, an incremental patch series:
* Simplify tests and unduplicate file paths.
* Unduplicate another file path.
* Use the shell builtin alternative for /bin/true.
* Removed useless 'SET' variable.
* The numlockx state documentation and the script don't match.
* Resonably handle the undocumented 'keep' state; do nothing.
* Support for 'toogle' state added.
* Untabified.


-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-3-686-pae (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages numlockx depends on:
ii  libc6     2.13-35
ii  libx11-6  2:1.5.0-1
ii  libxext6  2:1.3.1-2
ii  libxtst6  2:1.2.1-1

numlockx recommends no packages.

Versions of packages numlockx suggests:
pn  x-display-manager  <none>

-- Configuration Files:
/etc/X11/Xsession.d/55numlockx changed:
NUMLOCK=auto
cf=/etc/default/numlockx
[ ! -r $cf ] || . $cf
nlx=/usr/bin/numlockx
[ ! -x $nlx ] || {
    case $NUMLOCK in
        # 'keep' is an undocumented state (see `man 1 numlockx'), though
        # /etc/default/numlockx mentions it; do nothing
        keep)
            return 0
            ;;
        off|on|toggle)
            ;;
        *)
            NUMLOCK=on
            ltd=/usr/sbin/laptop-detect
            [ ! -x $ltd ] || ! $ltd || NUMLOCK=off
            ;;
    esac
    $nlx $NUMLOCK || :
}


-- no debconf information


Cheers,

-- 
Cristian
commit 33ebb3fdfee23b12f064314d96c5ebe3663e042d
Author: Cristian Ionescu-Idbohrn <cristian.ionescu-idbo...@axis.com>
Date:   Sat Aug 11 14:53:04 2012 +0200

    Simplify tests and unduplicate file paths.
    
    Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbo...@axis.com>

diff --git a/debian/55numlockx b/debian/55numlockx
index e4adad0..4975ffd 100644
--- a/debian/55numlockx
+++ b/debian/55numlockx
@@ -4,12 +4,11 @@
 NUMLOCK=auto
 
 # Load configuration
-if [ -f /etc/default/numlockx ] ; then
-    . /etc/default/numlockx
-fi
+cf=/etc/default/numlockx
+[ ! -r $cf ] || . $cf
 
 # Toggle numlock if we're not removed
-if [ -x /usr/bin/numlockx ] ; then
+[ ! -x /usr/bin/numlockx ] || {
     case $NUMLOCK in
         off|on)
             SET=1
@@ -20,14 +19,11 @@ if [ -x /usr/bin/numlockx ] ; then
         *)
             SET=1
             NUMLOCK=on
-            if [ -x /usr/sbin/laptop-detect ]; then
-                if /usr/sbin/laptop-detect; then
-                    NUMLOCK=off
-                fi
-            fi
+	    ltd=/usr/sbin/laptop-detect
+            [ ! -x $ltd ] || ! $ltd || NUMLOCK=off
             ;;
     esac
     /usr/bin/numlockx $NUMLOCK || /bin/true
-fi
+}
 
 # EOF

commit 6af532fe82764e60d7c41415528f36f6885c3413
Author: Cristian Ionescu-Idbohrn <cristian.ionescu-idbo...@axis.com>
Date:   Sat Aug 11 15:15:58 2012 +0200

    Unduplicate another file path.
    
    Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbo...@axis.com>

diff --git a/debian/55numlockx b/debian/55numlockx
index 4975ffd..4331dc5 100644
--- a/debian/55numlockx
+++ b/debian/55numlockx
@@ -8,7 +8,8 @@ cf=/etc/default/numlockx
 [ ! -r $cf ] || . $cf
 
 # Toggle numlock if we're not removed
-[ ! -x /usr/bin/numlockx ] || {
+nlx=/usr/bin/numlockx
+[ ! -x $nlx ] || {
     case $NUMLOCK in
         off|on)
             SET=1
@@ -23,7 +24,7 @@ cf=/etc/default/numlockx
             [ ! -x $ltd ] || ! $ltd || NUMLOCK=off
             ;;
     esac
-    /usr/bin/numlockx $NUMLOCK || /bin/true
+    $nlx $NUMLOCK || /bin/true
 }
 
 # EOF

commit 4ad88988a8a50be9461d21d8c7ba0eb810a4ac47
Author: Cristian Ionescu-Idbohrn <cristian.ionescu-idbo...@axis.com>
Date:   Sat Aug 11 15:16:55 2012 +0200

    Use the shell builtin alternative for /bin/true.
    
    Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbo...@axis.com>

diff --git a/debian/55numlockx b/debian/55numlockx
index 4331dc5..11e211f 100644
--- a/debian/55numlockx
+++ b/debian/55numlockx
@@ -24,7 +24,7 @@ nlx=/usr/bin/numlockx
             [ ! -x $ltd ] || ! $ltd || NUMLOCK=off
             ;;
     esac
-    $nlx $NUMLOCK || /bin/true
+    $nlx $NUMLOCK || :
 }
 
 # EOF

commit 7f1d08a10cf3f8a452970b8578dc6eac36ca16ef
Author: Cristian Ionescu-Idbohrn <cristian.ionescu-idbo...@axis.com>
Date:   Sat Aug 11 15:44:28 2012 +0200

    Removed useless 'SET' variable.
    Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbo...@axis.com>

diff --git a/debian/55numlockx b/debian/55numlockx
index 11e211f..d7ab86c 100644
--- a/debian/55numlockx
+++ b/debian/55numlockx
@@ -11,16 +11,11 @@ cf=/etc/default/numlockx
 nlx=/usr/bin/numlockx
 [ ! -x $nlx ] || {
     case $NUMLOCK in
-        off|on)
-            SET=1
-            ;;
-        keep)
-            SET=0
+        off|on|keep)
             ;;
         *)
-            SET=1
             NUMLOCK=on
-	    ltd=/usr/sbin/laptop-detect
+            ltd=/usr/sbin/laptop-detect
             [ ! -x $ltd ] || ! $ltd || NUMLOCK=off
             ;;
     esac

commit 7514c19d57e5c07041a6a54656152c958be8f2f2
Author: Cristian Ionescu-Idbohrn <cristian.ionescu-idbo...@axis.com>
Date:   Sat Aug 11 15:57:12 2012 +0200

    The numlockx state documentation and the script don't match.
    
    Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbo...@axis.com>

diff --git a/debian/55numlockx b/debian/55numlockx
index d7ab86c..50a99fa 100644
--- a/debian/55numlockx
+++ b/debian/55numlockx
@@ -11,6 +11,9 @@ cf=/etc/default/numlockx
 nlx=/usr/bin/numlockx
 [ ! -x $nlx ] || {
     case $NUMLOCK in
+	# FIXME: 'keep' is _not_ a documented state
+	#        'toggle' _is_, but not handled here
+	#        see even /etc/default/numlockx documentation
         off|on|keep)
             ;;
         *)

commit 0bf4eb1cf571d6e5a08a06803b0f7cc7ac917f4c
Author: Cristian Ionescu-Idbohrn <cristian.ionescu-idbo...@axis.com>
Date:   Sat Aug 11 17:46:05 2012 +0200

    Resonably handle the undocumented 'keep' state; do nothing.
    
    Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbo...@axis.com>

diff --git a/debian/55numlockx b/debian/55numlockx
index 50a99fa..f791574 100644
--- a/debian/55numlockx
+++ b/debian/55numlockx
@@ -11,11 +11,14 @@ cf=/etc/default/numlockx
 nlx=/usr/bin/numlockx
 [ ! -x $nlx ] || {
     case $NUMLOCK in
-	# FIXME: 'keep' is _not_ a documented state
-	#        'toggle' _is_, but not handled here
-	#        see even /etc/default/numlockx documentation
-        off|on|keep)
+        # FIXME: 'toggle' _is_ a documented state, but not handled here
+        #        see even /etc/default/numlockx documentation
+        off|on)
             ;;
+	# 'keep' is an undocumented state (see `man 1 numlockx); do nothing
+	keep)
+	    return 0
+	    ;;
         *)
             NUMLOCK=on
             ltd=/usr/sbin/laptop-detect

commit a73df902876f7cdc06aa150ede3af9f7532ae031
Author: Cristian Ionescu-Idbohrn <cristian.ionescu-idbo...@axis.com>
Date:   Sat Aug 11 17:55:11 2012 +0200

    Support for 'toogle' state added.
    
    Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbo...@axis.com>

diff --git a/debian/55numlockx b/debian/55numlockx
index f791574..5380af8 100644
--- a/debian/55numlockx
+++ b/debian/55numlockx
@@ -11,14 +11,13 @@ cf=/etc/default/numlockx
 nlx=/usr/bin/numlockx
 [ ! -x $nlx ] || {
     case $NUMLOCK in
-        # FIXME: 'toggle' _is_ a documented state, but not handled here
-        #        see even /etc/default/numlockx documentation
-        off|on)
-            ;;
-	# 'keep' is an undocumented state (see `man 1 numlockx); do nothing
+	# 'keep' is an undocumented state (see `man 1 numlockx'), though
+        # /etc/default/numlockx mentions it; do nothing
 	keep)
 	    return 0
 	    ;;
+        off|on|toggle)
+	    ;;
         *)
             NUMLOCK=on
             ltd=/usr/sbin/laptop-detect

commit b0f3c3530dcb06978c01abc16fe0235370015bbd
Author: Cristian Ionescu-Idbohrn <cristian.ionescu-idbo...@axis.com>
Date:   Sat Aug 11 18:26:39 2012 +0200

    Untabified.
    
    Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbo...@axis.com>

diff --git a/debian/55numlockx b/debian/55numlockx
index 5380af8..bc0fbf2 100644
--- a/debian/55numlockx
+++ b/debian/55numlockx
@@ -11,13 +11,13 @@ cf=/etc/default/numlockx
 nlx=/usr/bin/numlockx
 [ ! -x $nlx ] || {
     case $NUMLOCK in
-	# 'keep' is an undocumented state (see `man 1 numlockx'), though
+        # 'keep' is an undocumented state (see `man 1 numlockx'), though
         # /etc/default/numlockx mentions it; do nothing
-	keep)
-	    return 0
-	    ;;
+        keep)
+            return 0
+            ;;
         off|on|toggle)
-	    ;;
+            ;;
         *)
             NUMLOCK=on
             ltd=/usr/sbin/laptop-detect

Reply via email to