X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=scripts.git;a=blobdiff_plain;f=hotspot.sh;h=a8a27ae5e550cfa4835c80b875fccc64d63a5069;hp=e3cac287ae3531caab3c10bfdcf651541cdf877f;hb=4ec5d5f4a0a407340f44e06e5b187053782a0470;hpb=88cc045a5eecced9d8f71c2a8e0aef67a8d94368 diff --git a/hotspot.sh b/hotspot.sh index e3cac28..a8a27ae 100755 --- a/hotspot.sh +++ b/hotspot.sh @@ -17,7 +17,10 @@ # Contact for comments & bug reports # ######################################################################### -INTERFACE=wlan0 +INTERFACE=${WIFI_INTERFACE} + +[[ ${INTERFACE} ]] || INTERFACE=wlan0 + MTU=512 SCAN_OUTPUT=$(mktemp /tmp/scanresult.XXXXXX) @@ -81,8 +84,8 @@ function scan () { -e "s/Quality=\([0-9]*\).*$/QUALITY,\1/" \ -e "s/Encryption key:/ENCRYPTION,/" | \ awk 'BEGIN { FS="," } - { - if($1 == "ESSID") { essid=$2 } + { + if($1 == "ESSID") { essid=$2 } else if($1 == "AP") { ap=$2 } else if($1 == "QUALITY") { quality=$2; } else if($1 == "ENCRYPTION") { @@ -258,6 +261,8 @@ if [[ $1 == "-k" ]]; then exit 1 fi +trap cleanup-before-quit EXIT + stty_state=$(stty -g) trap sigint-handler SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM @@ -295,58 +300,56 @@ while [[ ${cont} == 1 ]]; do ;; "") - process-key "down" - ;; + process-key "down" + ;; "") - process-key "up" - ;; + process-key "up" + ;; "") #$'\033'") - current_keymap=escape - ;; + current_keymap=escape + ;; *) - ;; - esac - ;; + ;; + esac + ;; - escape) ################################################## - case ${CHAR} in - "$'\033'") + escape) ################################################## + case ${CHAR} in + "$'\033'") process-key "esc-esc" ;; - "[") + "[") current_keymap=cursor ;; - *) + *) current_keymap=default ;; - esac - ;; + esac + ;; - cursor) ################################################## + cursor) ################################################## - current_keymap=default + current_keymap=default - case ${CHAR} in - A) + case ${CHAR} in + A) process-key "up" ;; - B) + B) process-key "down" ;; - *) - ;; - esac - ;; - *) - echo "Unknown keymap. This is an internal and weird bug." - cont=0 - ;; - esac + ;; + esac + ;; - done + *) + echo "Unknown keymap. This is an internal and weird bug." + cont=0 + ;; + esac - cleanup-before-quit +done