diff --git a/src/speedwm-netctrl b/src/speedwm-netctrl index d9cef0f..ff98807 100755 --- a/src/speedwm-netctrl +++ b/src/speedwm-netctrl @@ -25,15 +25,23 @@ getdevice() { #[ -z "$seldevice" ] && exit 0 } +listentries() { + printf "%s\nā€Ž\nDisconnect\nExit\n" "$(iwctl station "$seldevice" get-networks | sed -n 6,20p | sed "s|>||g" | awk '{ print $1 }')" | sed "s| |No networks found|g" > /tmp/netctrl-file + sleep 3 + listentries +} + # connect to wifi connectwifi() { # if args aren't disconnect, scan for networks # if it is disconnect, disconnect if [ "$INARGS" != "disconnect" ]; then iwctl station $seldevice scan - network="$(printf "%s\nā€Ž\nRefresh\nDisconnect\nExit" \ - "$(iwctl station "$seldevice" get-networks | sed -n 6,20p | sed "s|>||g" | awk '{ print $1 }')" | sed "s| |No networks found|g" | \ - $RUNLAUNCHER -l 10 -g 1 -p "Select a network to connect to" | sed "s|ā€Ž||g")" + rm -f /tmp/netctrl-file + + listentries & + + network="$($RUNLAUNCHER -lf /tmp/netctrl-file -l 10 -g 1 -p "Select a network to connect to" | sed "s|ā€Ž||g")" # check output case "$network" in @@ -41,14 +49,13 @@ connectwifi() { "No networks found") exit 0 ;; "Disconnect") disconnect=true ;; "Exit") exit 0 ;; - "Refresh") getdevice "$@" && connectwifi "$@" ;; esac else disconnect=true fi if [ "$disconnect" != "true" ]; then - iwctl station "$seldevice" get-networks | grep "$network" > /dev/null || exit 1 + iwctl station "$seldevice" get-networks | grep -q "$network" || exit 1 connect_pass() { iwctl station "$seldevice" disconnect