Initial Commit

This commit is contained in:
2026-04-18 15:05:01 +01:00
commit 801c9d74d0
22 changed files with 644 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Fetch the active connection name and type
# -t: Terse output
# -f: Specific fields
ACTIVE_CONN=$(nmcli -t -f NAME,TYPE connection show --active | grep -E '802-3-ethernet|802-11-wireless' | head -n 1)
# If no connection is found, output nothing
if [ -z "$ACTIVE_CONN" ]; then
echo ""
exit 0
fi
# Extract the name and type using parameter expansion (faster than cut)
CONN_NAME="${ACTIVE_CONN%%:*}"
CONN_TYPE="${ACTIVE_CONN##*:}"
# Output JSON for Waybar custom module
if [[ "$CONN_TYPE" == *"802-11-wireless"* ]]; then
# It's Wi-Fi
echo "{\"text\": \"$CONN_NAME \", \"class\": \"wifi\"}"
else
# It's Ethernet
echo "{\"text\": \"$CONN_NAME 󰊗\", \"class\": \"ethernet\"}"
fi