[bin/qrwifi] Add interactive mode
to choose a saved network to share
This commit is contained in:
parent
f622651482
commit
b83a91e303
1 changed files with 14 additions and 1 deletions
13
bin/qrwifi
13
bin/qrwifi
|
@ -1,5 +1,18 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
DMENU="$(which dmenu 2>/dev/null)"
|
||||||
|
if [ -z "$DMENU" ]; then
|
||||||
|
DMENU="$(which rofi) -dmenu"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${1:-}" = -i ] || [ "${1:-}" = --interactive ]; then
|
||||||
|
ssid="$(sudo cat /etc/wpa_supplicant/wpa_supplicant.conf | sed -n '/^[\t ]*ssid="[^"][^"]*"$/{:findpsk;N;/}/d;/\n[\t ]*psk=/!b findpsk;s/^\(\n\|.\)*[\t ]*ssid="\([^"]*\)"\(\n\|.\)*$/\2/p; }' | $DMENU)"
|
||||||
|
if [ -z "$ssid" ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
ssid="${1:-}"
|
ssid="${1:-}"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$ssid" ]; then
|
if [ -z "$ssid" ]; then
|
||||||
ssid="$(wpa_cli status | rg -o --replace='$1' '^ssid=(.*)$')"
|
ssid="$(wpa_cli status | rg -o --replace='$1' '^ssid=(.*)$')"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue