The deployed config pinned "output": "eDP-1", the laptop's internal display. On the PC waybar started fine but never mapped a layer surface, so there was no bar and SIGUSR1 had nothing to toggle. Listed both profiles' primaries instead -- waybar skips names that are not connected, so the one file works on the laptop and the PC. Two bugs in the same config that this uncovered: - bars/main.jsonc included modules/temperature.cpu.jsonc, but the file is temperature-cpu.jsonc, so the temperature#cpu module the bar referenced was silently absent. - get_wg_status.sh ran `sudo wg show` with no tty, logging "a terminal is required to read the password" on every poll. Now `sudo -n`, which fails instantly and falls into the existing "disconnected" branch, and starts working as-is if a NOPASSWD rule is ever added. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01StGBghPW9Dm7z7uj2VNWHr
59 lines
2.0 KiB
Bash
Executable File
59 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Function to format output as JSON
|
|
function format {
|
|
local tooltip=""
|
|
local first=true
|
|
|
|
while IFS= read -r line; do
|
|
if [[ -z "$line" ]]; then
|
|
continue
|
|
fi
|
|
|
|
# Check if the line starts with "interface" or "peer"
|
|
if [[ "$line" == interface:* ]]; then
|
|
if [ "$first" = false ]; then
|
|
tooltip+="\n"
|
|
fi
|
|
tooltip+="Interface: <b>${line#*: }</b>"
|
|
first=false
|
|
elif [[ "$line" == peer:* ]]; then
|
|
if [ "$first" = false ]; then
|
|
tooltip+="\n"
|
|
fi
|
|
tooltip+="Peer: <b>${line#*: }</b>"
|
|
first=false
|
|
elif [[ "$line" == *"received,"* ]]; then
|
|
# Extract received and sent data
|
|
received=$(echo "$line" | grep -oP '\d+\.\d+ (B|KiB|MiB|GiB) received' | awk '{print $1 " " $2}')
|
|
sent=$(echo "$line" | grep -oP '\d+\.\d+ (B|KiB|MiB|GiB) sent' | awk '{print $1 " " $2}')
|
|
tooltip+="\n<span foreground='#eed49f'> $received</span> <span foreground='#b7bdf8'> $sent</span>"
|
|
else
|
|
# For other lines
|
|
if [ "$first" = false ]; then
|
|
tooltip+="\n"
|
|
fi
|
|
key=$(echo "$line" | sed "s/ //" | awk -F ': ' '{print $1}')
|
|
value=$(echo "$line" | awk -F ': ' '{print $2}')
|
|
tooltip+="$key: <b>$value</b>"
|
|
first=false
|
|
fi
|
|
done
|
|
|
|
echo "$tooltip"
|
|
}
|
|
|
|
# Read wg show output and format
|
|
# -n so a missing NOPASSWD sudoers rule fails instantly instead of blocking
|
|
# the module on a password prompt it has no terminal to ask on.
|
|
wg_show_output=$(sudo -n wg show 2>/dev/null)
|
|
|
|
if [[ -z $wg_show_output ]]; then
|
|
echo "{ \"text\": \"---\", \"tooltip\": \"disconnected\", \"class\": \"\", \"percentage\": 0 }"
|
|
else
|
|
tooltip=$(echo "$wg_show_output" | format)
|
|
echo "{ \"text\": \"$(echo $wg_show_output | grep -o 'wg[0-9]*')\", \"tooltip\": \"$tooltip\", \"class\": \"\", \"percentage\": 0 }"
|
|
fi
|
|
|
|
|