summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2014-03-03 10:42:32 +0100
committerJouke Witteveen <j.witteveen@gmail.com>2014-03-03 10:42:32 +0100
commit39f35c0beec935a894821b239247cde3b79d7b4a (patch)
treef0401894ba1324d657d038d821c5ff01797bfc16
parent79442a6fb85b22b495885175a34d4e4d1f5dc16d (diff)
downloadnetctl-39f35c0beec935a894821b239247cde3b79d7b4a.tar.gz
netctl-39f35c0beec935a894821b239247cde3b79d7b4a.tar.xz
Fix rfkill unblocking through rf_enable
After 755c8d5, rf_enable did not know the rfkill path anymore. Observed by: Tom <reztho@archlinux.us>
-rw-r--r--src/lib/rfkill42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/lib/rfkill b/src/lib/rfkill
index 3f841f3..05c1382 100644
--- a/src/lib/rfkill
+++ b/src/lib/rfkill
@@ -40,34 +40,44 @@ rf_status() {
fi
}
+## Set the soft blocking status of an rfkill device
+# $1: blocking status
+# $2: interface name
+# $3: rfkill name
+rf_set() {
+ local block=$1 path
+ shift
+ path=$(rf_get_path "$@") || return 1
+
+ report_debug "${FUNCNAME[1]}: echo '$block' > '$path/soft'"
+ echo "$block" > "$path/soft"
+ timeout_wait 1 '(( $(< "$path/soft") == block ))'
+}
+
+## Block transmission through a wireless device
+# $1: interface name
+# $2: rfkill name
+rf_disable() {
+ rf_set 1 "$@"
+}
+
## Unblock transmission through a wireless device
# $1: interface name
# $2: rfkill name
rf_enable() {
- case $(rf_status "$@") in
+ local status
+ status=$(rf_status "$@") || return 1
+
+ case $status in
hard)
report_error "Transmission is hard-blocked on interface '$interface'"
return 1
;;
soft)
- report_debug "$FUNCNAME: echo 0 > '$path/soft'"
- echo 0 > "$path/soft"
- timeout_wait 1 '(( ! $(< "$path/soft") ))'
+ rf_set 0 "$@"
;;
esac
}
-## Block transmission through a wireless device
-# $1: interface name
-# $2: rfkill name
-rf_disable() {
- local path
- path=$(rf_get_path "$@") || return 1
-
- report_debug "$FUNCNAME: echo 1 > '$path/soft'"
- echo 1 > "$path/soft"
- timeout_wait 1 '(( $(< "$path/soft") ))'
-}
-
# vim: ft=sh ts=4 et sw=4: