projects
/
scripts.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added the percentage of disk usage.
[scripts.git]
/
hotspot.sh
diff --git
a/hotspot.sh
b/hotspot.sh
index
1cd5a22
..
a8a27ae
100755
(executable)
--- a/
hotspot.sh
+++ b/
hotspot.sh
@@
-17,7
+17,10
@@
# Contact <francois@fleuret.org> for comments & bug reports #
#########################################################################
# Contact <francois@fleuret.org> for comments & bug reports #
#########################################################################
-INTERFACE=wlan0
+INTERFACE=${WIFI_INTERFACE}
+
+[[ ${INTERFACE} ]] || INTERFACE=wlan0
+
MTU=512
SCAN_OUTPUT=$(mktemp /tmp/scanresult.XXXXXX)
MTU=512
SCAN_OUTPUT=$(mktemp /tmp/scanresult.XXXXXX)
@@
-70,6
+73,8
@@
function sigint-handler () {
}
function scan () {
}
function scan () {
+ echo
+ echo " Scanning ..."
iwconfig ${INTERFACE} ap off essid ""
iwlist ${INTERFACE} scan | \
sed -e "s/^[\t ]*//" | grep ^"Cell\|ESSID\|Quality\|Encryption" | \
iwconfig ${INTERFACE} ap off essid ""
iwlist ${INTERFACE} scan | \
sed -e "s/^[\t ]*//" | grep ^"Cell\|ESSID\|Quality\|Encryption" | \
@@
-79,8
+84,8
@@
function scan () {
-e "s/Quality=\([0-9]*\).*$/QUALITY,\1/" \
-e "s/Encryption key:/ENCRYPTION,/" | \
awk 'BEGIN { FS="," }
-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") {
else if($1 == "AP") { ap=$2 }
else if($1 == "QUALITY") { quality=$2; }
else if($1 == "ENCRYPTION") {
@@
-172,7
+177,7
@@
function process-key () {
e) # Selects essid + dhcp
SELECTED=$(get-selected-essid-ap)
ESSID=$(echo ${SELECTED} | cut -f 1 -d,)
e) # Selects essid + dhcp
SELECTED=$(get-selected-essid-ap)
ESSID=$(echo ${SELECTED} | cut -f 1 -d,)
- echo "Running DHCP on ${INTERFACE} for ESSID
${ESSID}
."
+ echo "Running DHCP on ${INTERFACE} for ESSID
\"${ESSID}\"
."
iwconfig ${INTERFACE} ap auto essid "${ESSID}"
kill-dhcp
echo
iwconfig ${INTERFACE} ap auto essid "${ESSID}"
kill-dhcp
echo
@@
-189,7
+194,7
@@
function process-key () {
SELECTED=$(get-selected-essid-ap)
ESSID=$(echo ${SELECTED} | cut -f 1 -d,)
AP=$(echo ${SELECTED} | cut -f 2 -d,)
SELECTED=$(get-selected-essid-ap)
ESSID=$(echo ${SELECTED} | cut -f 1 -d,)
AP=$(echo ${SELECTED} | cut -f 2 -d,)
- echo "Running DHCP on ${INTERFACE} for ESSID
${ESSID}
and AP ${AP}."
+ echo "Running DHCP on ${INTERFACE} for ESSID
\"${ESSID}\"
and AP ${AP}."
iwconfig ${INTERFACE} ap ${AP} essid "${ESSID}"
kill-dhcp
echo
iwconfig ${INTERFACE} ap ${AP} essid "${ESSID}"
kill-dhcp
echo
@@
-210,14
+215,12
@@
function process-key () {
;;
r|s) # re-scanning the access points
;;
r|s) # re-scanning the access points
- echo "Scanning ..."
scan
redisplay
;;
m) # Switching the mode to show the protected spots
SHOW_CLOSED=$((1-SHOW_CLOSED))
scan
redisplay
;;
m) # Switching the mode to show the protected spots
SHOW_CLOSED=$((1-SHOW_CLOSED))
- echo "Scanning ..."
scan
redisplay
;;
scan
redisplay
;;
@@
-239,7
+242,7
@@
function process-key () {
;;
"esc-esc"|q)
;;
"esc-esc"|q)
- echo "
quit
"
+ echo "
Quit.
"
cont=0
;;
cont=0
;;
@@
-258,6
+261,8
@@
if [[ $1 == "-k" ]]; then
exit 1
fi
exit 1
fi
+trap cleanup-before-quit EXIT
+
stty_state=$(stty -g)
trap sigint-handler SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM
stty_state=$(stty -g)
trap sigint-handler SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM
@@
-295,58
+300,56
@@
while [[ ${cont} == 1 ]]; do
;;
"
\ e
")
;;
"
\ e
")
- process-key "down"
- ;;
+
process-key "down"
+
;;
"
\10
")
"
\10
")
- process-key "up"
- ;;
+
process-key "up"
+
;;
"
\e
") #$'\033'")
"
\e
") #$'\033'")
- current_keymap=escape
- ;;
+
current_keymap=escape
+
;;
*)
*)
- ;;
-
esac
-
;;
+
;;
+ esac
+ ;;
-
escape) ##################################################
-
case ${CHAR} in
-
"$'\033'")
+ escape) ##################################################
+ case ${CHAR} in
+ "$'\033'")
process-key "esc-esc"
;;
process-key "esc-esc"
;;
-
"[")
+ "[")
current_keymap=cursor
;;
current_keymap=cursor
;;
-
*)
+ *)
current_keymap=default
;;
current_keymap=default
;;
-
esac
-
;;
+ esac
+ ;;
-
cursor) ##################################################
+ cursor) ##################################################
-
current_keymap=default
+ current_keymap=default
-
case ${CHAR} in
-
A)
+ case ${CHAR} in
+ A)
process-key "up"
;;
process-key "up"
;;
-
B)
+ B)
process-key "down"
;;
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