diff options
author | William Giokas <1007380@gmail.com> | 2013-01-24 13:13:10 +0100 |
---|---|---|
committer | Jouke Witteveen <j.witteveen@gmail.com> | 2013-01-24 13:13:10 +0100 |
commit | dd68d1f11adbe005ad3b21e0261099b7930995f5 (patch) | |
tree | 0d8075e22439ed85048c9a66b21a4520b685a2b0 | |
parent | e5125bb4569b903ea3f84895c80b4476641068f4 (diff) | |
download | netctl-dd68d1f11adbe005ad3b21e0261099b7930995f5.tar.gz netctl-dd68d1f11adbe005ad3b21e0261099b7930995f5.tar.xz |
[wifi-menu] Autodetect network interfaces
After the systemd 197 device name changes, wlan0 no longer exists (it
does for people who mask the rule, but new users will have issues with
this). This just searches the /sys/class/net directory for wireless
names. If there is more than one, then report an
"Invalid interface specification", not a "Missing" interface (as there
could be multiple).
A quick thanks to Dave Reisner for his help in the channel.
Altered by: Jouke Witteveen <j.witteveen@gmail.com>
-rwxr-xr-x | src/wifi-menu | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/wifi-menu b/src/wifi-menu index b79eebe..2b2e700 100755 --- a/src/wifi-menu +++ b/src/wifi-menu @@ -7,15 +7,15 @@ usage() { cat << END -Usage: wifi-menu [-h | --help] [-o | --obscure] [interface] +Usage: wifi-menu [-h | --help] [-o | --obscure] [INTERFACE] -Interactively connect to a wireless network. +Interactively connect to a wireless network on INTERFACE using netctl. +If only one wireless interface is available, INTERFACE can be omitted. Arguments: - -h, --help Show this help. + -h, --help Show this help -o, --obscure Show asterisks for the characters of the password - and store the password as a hexadecimal string. - interface The wireless interface to use (default: wlan0). + and store the password as a hexadecimal string END } @@ -170,7 +170,7 @@ while [[ "$1" = -* ]]; do shift ;; -*) - report_err "Invalid option: $1" + report_error "Invalid option: $1" usage exit 255 ;; @@ -187,11 +187,16 @@ if ! type dialog &> /dev/null; then exit_error "Please install 'dialog' to use wifi-menu" fi -INTERFACE=${1-wlan0} +INTERFACE=$1 if [[ -z "$INTERFACE" ]]; then - report_error "Missing interface specification" - usage - exit 255 + INTERFACE=(/sys/class/net/*/wireless/) + if [[ "${#INTERFACE[@]}" -ne 1 || ! -d "$INTERFACE" ]]; then + report_error "Invalid interface specification" + usage + exit 255 + fi + INTERFACE=${INTERFACE:15:-10} + report_debug "Using interface '$INTERFACE'" fi cd / # We do not want to spawn anything that can block unmounting |