[Debian-eeepc-commits] [SCM] Maintenance of eeepc-acpi-scripts debian package branch, rfkill, updated. 1.1.5-19-g316af4b

Darren Salt linux at youmustbejoking.demon.co.uk
Tue Jan 12 16:47:54 UTC 2010


The following commit has been merged in the rfkill branch:
commit 316af4b7a94b7127d2824949e4e59d56f82e05be
Author: Darren Salt <linux at youmustbejoking.demon.co.uk>
Date:   Mon Jan 4 15:53:29 2010 +0000

    Modify the wwan toggle code to use rfkill(8).

diff --git a/etc/acpi/actions/gsm.sh b/etc/acpi/actions/gsm.sh
index 1c106f4..f0bd4cb 100644
--- a/etc/acpi/actions/gsm.sh
+++ b/etc/acpi/actions/gsm.sh
@@ -8,13 +8,24 @@ FUNC_LIB=/usr/share/$PKG/functions.sh
 . $FUNC_LIB
 
 # first try kernel rfkill
-detect_rfkill eeepc-wwan3g
+detect_rfkill eeepc-wwan3g wwan
+
 if [ -n "$RFKILL" ]; then
-    if echo `cat $RFKILL` > $RFKILL 2> /dev/null; then
+    if have_dev_rfkill; then
+	gsm_control=wwan
+    elif echo `cat $RFKILL` > $RFKILL 2> /dev/null; then
         gsm_control="$RFKILL"
-        gsm_on=1
-        gsm_off=0
     fi
+
+    get_gsm_rfkill ()
+    {
+	get_rfkill "$RFKILL"
+    }
+
+    set_gsm_rfkill ()
+    {
+	set_rfkill "$RFKILL" "$1"
+    }
 fi
 
 # then try USB
@@ -27,6 +38,20 @@ if [ -z "$gsm_control" ]; then
             break
 	fi
     done
+
+    get_gsm_rfkill ()
+    {
+	[ `cat "$gsm_control"` != "$gsm_off" ] && echo 1 || echo 0
+    }
+
+    set_gsm_rfkill ()
+    {
+	if [ "$1" = 1 ]; then
+            echo "$gsm_off" > "$gsm_control"
+        else
+            echo "$gsm_on" > "$gsm_control"
+        fi
+    }
 fi
 
 # give up if no method to toggle GSM was found
@@ -35,26 +60,20 @@ if [ -z "$gsm_control" ]; then
     exit 1
 fi
 
+STATE="$(get_gsm_rfkill)"
+
 case "$1" in
     detect)
-        if [ `cat "$gsm_control"` != "$gsm_off" ]; then
-            exit 1
-        else
-            exit 0
-        fi
+	exit "$STATE"
 	;;
     toggle)
-        if [ `cat "$gsm_control"` != "$gsm_off" ]; then
-            echo "$gsm_off" > "$gsm_control"
-        else
-            echo "$gsm_on" > "$gsm_control"
-        fi        
+	set_gsm_rfkill $((1-$STATE))
         ;;
     on|enable|1)
-        echo "$gsm_on" > "$gsm_control"
+	set_gsm_rfkill 1
 	;;
     off|disable|0)
-        echo "$gsm_off" > "$gsm_control"
+	set_gsm_rfkill 0
 	;;
     *)
 	echo "Usage: $0 [on|off|detect|toggle]"

-- 
Maintenance of eeepc-acpi-scripts debian package



More information about the Debian-eeepc-commits mailing list