From dd68d1f11adbe005ad3b21e0261099b7930995f5 Mon Sep 17 00:00:00 2001 From: William Giokas <1007380@gmail.com> Date: Thu, 24 Jan 2013 13:13:10 +0100 Subject: [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 --- src/wifi-menu | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/wifi-menu') 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 -- cgit v1.2.3-24-g4f1b