1
0
Fork 0
gnu-plus-dotfiles/dot_config/sway/wifi-menu.sh
rain 27ae3a3b18 sway: drop -t 2000/-t 3000 from notify-send, source restore-wayland-env in toggle-dropdown/wifi-menu
The actual cause of 'caffeine notification doesn't show' was the
-t 2000 timeout: the notification popped for 2 seconds and self-cleared
before the user could see it. Manual notify-send from a terminal (no
-t flag) used mako's default-timeout=5000 and was visible — so the user
saw my test notifications but not their own clicks.

Fix: drop the -t flag everywhere so mako config owns the duration.
Added: source restore-wayland-env.sh in toggle-dropdown.sh and
wifi-menu.sh — same env-loss pattern as caffeine.sh, would have
been next on the bug list.

Verified on tadbit: -t 2000 notification visible at +0.5s, gone at
+2.5s (user missed it). No -t flag: visible at +0.5s, gone at +5.5s
(visible long enough to read).
2026-06-23 22:24:16 -04:00

38 lines
1.5 KiB
Bash
Executable file

#!/bin/bash
# wifi-menu.sh — wofi-based WiFi network picker using nmcli
# Lists available networks, connects on selection.
#
# wofi needs WAYLAND_DISPLAY (it IS a Wayland client itself, so it can
# usually find the socket, but on a non-standard socket it's safer to
# be explicit). Source restore-wayland-env.sh at the top.
# shellcheck source=restore-wayland-env.sh
source "$HOME/.config/sway/restore-wayland-env.sh"
# 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. No -t flag → mako's default-timeout (5000ms) controls the duration.
# Earlier used -t 3000/-t 5000; the inconsistency meant the user could
# blink and miss the success notification. Let mako config drive the value.
nmcli device wifi connect "$SSID" 2>&1 | grep -q "successfully" && \
notify-send "WiFi" "Connected to $SSID" || \
notify-send "WiFi" "Failed to connect to $SSID"