added wifi_list and wifi_show
This commit is contained in:
parent
1446cc9948
commit
38e3927370
|
|
@ -100,3 +100,42 @@ backup() {
|
|||
urlencode() {
|
||||
echo -n "$1" | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g'
|
||||
}
|
||||
|
||||
# ---- Config ----
|
||||
# Preferred networks (higher = more preferred)
|
||||
declare -A WIFI_PRIORITY=(
|
||||
["HomeWiFi"]=100
|
||||
["WorkWiFi"]=90
|
||||
["PhoneHotspot"]=80
|
||||
)
|
||||
|
||||
# ---- Helpers ----
|
||||
_wifi_scan() {
|
||||
nmcli -t -f IN-USE,SSID,SIGNAL,SECURITY dev wifi list \
|
||||
| sed '/^::/d' | sort -t: -k3 -nr
|
||||
}
|
||||
|
||||
# ---- List ----
|
||||
wifi_list() {
|
||||
nmcli -f IN-USE,SSID,SIGNAL,SECURITY dev wifi list
|
||||
}
|
||||
|
||||
# ---- FZF Connect ----
|
||||
wifi_show() {
|
||||
command -v fzf >/dev/null || { echo "fzf not installed"; return 1; }
|
||||
|
||||
local choice ssid
|
||||
choice=$(_wifi_scan | fzf --delimiter=: --with-nth=2,3,4 --prompt="Select Wi-Fi: ")
|
||||
|
||||
[ -z "$choice" ] && return 1
|
||||
ssid=$(echo "$choice" | cut -d: -f2)
|
||||
|
||||
read -s -p "Password (leave empty if open): " password
|
||||
echo
|
||||
|
||||
if [ -z "$password" ]; then
|
||||
nmcli dev wifi connect "$ssid"
|
||||
else
|
||||
nmcli dev wifi connect "$ssid" password "$password"
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
export EDITOR=vim
|
||||
export VISUAL=vim
|
||||
Loading…
Reference in New Issue