diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/rfkill | 42 |
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: |