1
0
Fork 0
gnu-plus-dotfiles/dot_config/sway/wifi-menu.sh
rain 6bbaa8f2f5 Add sway/wofi/foot Wayland desktop stack with per-host toggle
New opt-in feature for x86_64 desktops: sway + wofi + foot + swaybg +
swaylock + swayidle + grim + slurp + waybar + wl-clipboard. mako on
arch, dunst on debian (mako isn't packaged for debian).

Files:
- .chezmoi.yaml.tmpl: added data.sway flag (true on miche/byte/kaiser,
  false on Pis). Override per host with ~/.config/chezmoi/features/sway
  or ~/.config/chezmoi/features/no-sway marker files.
- run_once_40-install-sway.sh.tmpl: installs packages if .sway=true,
  exits 0 otherwise. Sets up the marker file.
- dot_config/{sway,foot,wofi,waybar,mako}/: existing configs from miche.

Per-host toggle workflow:
  # On any box, enable sway:
  touch ~/.config/chezmoi/features/sway
  chezmoi apply

  # On a sway-enabled box, disable it:
  touch ~/.config/chezmoi/features/no-sway
  rm ~/.config/chezmoi/features/sway
  chezmoi apply

Currently sway packages are already installed on miche (existed before
this commit). Byte will get them via the new run_once_40 script.
Pis (rye, crouton) are unaffected — install script early-returns.
2026-06-22 14:23:56 -04:00

29 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
# wifi-menu.sh — wofi-based WiFi network picker using nmcli
# Lists available networks, connects on selection.
# Get list of networks: SSID, signal, security
SELECTED=$(nmcli -t -f SSID,SIGNAL,SECURITY device wifi list --rescan yes 2>/dev/null | \
grep -v '^$' | \
sort -t: -k2 -nr | \
awk -F: '{
sig = $2 + 0
if (sig > 75) bars = "████"
else if (sig > 50) bars = "███░"
else if (sig > 25) bars = "██░░"
else bars = "█░░░"
sec = ($3 != "" && $3 != "--") ? " 󰌾" : ""
printf "%s %s%s\n", bars, $1, sec
}' | \
wofi --dmenu --insensitive --prompt "WiFi" -W 400 -H 500 2>/dev/null)
# Exit if nothing selected
[ -z "$SELECTED" ] && exit 0
# Extract SSID (everything after the signal bars + spaces)
SSID=$(echo "$SELECTED" | sed 's/^[█░ ]* //; s/ 🔒$//')
# Connect
nmcli device wifi connect "$SSID" 2>&1 | grep -q "successfully" && \
notify-send -t 3000 "WiFi" "Connected to $SSID" || \
notify-send -t 5000 "WiFi" "Failed to connect to $SSID"