added wifi_list and wifi_show

This commit is contained in:
Stefan Friese 2026-03-25 21:56:04 +01:00
parent 1446cc9948
commit 38e3927370
2 changed files with 41 additions and 0 deletions

View File

@ -100,3 +100,42 @@ backup() {
urlencode() { urlencode() {
echo -n "$1" | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g' 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
}

2
bash/.bash_variables Normal file
View File

@ -0,0 +1,2 @@
export EDITOR=vim
export VISUAL=vim