Update 1
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
pkill waybar || waybar &
|
||||
pkill swaync || swaync &
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
# -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 no connection is found, output disconnected icon
|
||||
if [ -z "$ACTIVE_CONN" ]; then
|
||||
echo ""
|
||||
echo "{\"text\": \" \", \"class\": \"disconnected\"}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -18,8 +18,22 @@ 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\"}"
|
||||
SIGNAL=$(nmcli -t -f IN-USE,SIGNAL dev wifi | grep '^\*' | cut -d':' -f2)
|
||||
if [ -z "$SIGNAL" ]; then
|
||||
ICON=""
|
||||
elif [ "$SIGNAL" -ge 80 ]; then
|
||||
ICON=""
|
||||
elif [ "$SIGNAL" -ge 60 ]; then
|
||||
ICON=""
|
||||
elif [ "$SIGNAL" -ge 40 ]; then
|
||||
ICON=""
|
||||
elif [ "$SIGNAL" -ge 20 ]; then
|
||||
ICON=""
|
||||
else
|
||||
ICON=""
|
||||
fi
|
||||
echo "{\"text\": \"$CONN_NAME $ICON \", \"class\": \"wifi\"}"
|
||||
else
|
||||
# It's Ethernet
|
||||
echo "{\"text\": \"$CONN_NAME \", \"class\": \"ethernet\"}"
|
||||
echo "{\"text\": \"$CONN_NAME \", \"class\": \"ethernet\"}"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user