diff options
author | Ivan Shapovalov <intelfx100@gmail.com> | 2014-02-25 15:26:17 +0100 |
---|---|---|
committer | Jouke Witteveen <j.witteveen@gmail.com> | 2014-02-27 13:48:49 +0100 |
commit | f64a2f25d435edd3507e477a25cb4c4e15297794 (patch) | |
tree | 39f5c2da88946e33c0a4b2314b6f4e358f88e296 | |
parent | 349f9b0360f6f7305475fca57656f9e187d859d2 (diff) | |
download | netctl-f64a2f25d435edd3507e477a25cb4c4e15297794.tar.gz netctl-f64a2f25d435edd3507e477a25cb4c4e15297794.tar.xz |
wifi-menu: handle interface's rfkill switch
Temporarily enable the interface's rfkill (if specified) before issuing a scan
and restore its state afterwards.
-rwxr-xr-x | src/wifi-menu | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/wifi-menu b/src/wifi-menu index 80eadd4..9efa2c0 100755 --- a/src/wifi-menu +++ b/src/wifi-menu @@ -2,6 +2,7 @@ . /usr/lib/network/globals . "$SUBR_DIR/wpa" +. "$SUBR_DIR/rfkill" usage() @@ -236,16 +237,31 @@ if [[ -z "$INTERFACE" ]]; then INTERFACE=${INTERFACE:15:-10} report_debug "Using interface '$INTERFACE'" fi +if [[ -x "$PROFILE_DIR/interfaces/$INTERFACE" ]]; then + source "$PROFILE_DIR/interfaces/$INTERFACE" +fi cd / # We do not want to spawn anything that can block unmounting if [[ ! -d "/sys/class/net/$INTERFACE" ]]; then exit_error "No such interface: $INTERFACE" fi +if [[ "$RFKill" && "$(rf_status "$INTERFACE" "$RFKill")" ]]; then + if ! rf_enable "$INTERFACE" "$RFKill"; then + exit_error "Could not unblock transmission on interface '$INTERFACE'" + fi + RF_UNBLOCKED=1 +fi echo -n "Scanning for networks... " CONNECTION=$(wpa_call "$INTERFACE" status 2> /dev/null | sed -n "s/^ssid=//p") NETWORKS=$(wpa_supplicant_scan "$INTERFACE" 3,4,5) -if [[ $? -eq 0 ]]; then +RETURN=$? + +if (( RF_UNBLOCKED )); then + rf_disable "$INTERFACE" "$RFKill" +fi + +if (( RETURN == 0 )); then trap 'rm -f "$NETWORKS"' EXIT echo "done" init_profiles "$INTERFACE" |