diff --git a/waybar/config.json b/waybar/config.json index 082e849..e9fe438 100644 --- a/waybar/config.json +++ b/waybar/config.json @@ -3,7 +3,7 @@ "height": 35, "modules-left": ["sway/workspaces", "sway/mode", "custom/media"], "modules-center": ["sway/window"], - "modules-right": ["pulseaudio", "network", "cpu", "memory", "backlight", "battery", "clock", "tray", "idle_inhibitor"], + "modules-right": ["pulseaudio", "custom/network","backlight", "battery", "clock", "tray", "idle_inhibitor"], "sway/workspaces": { "disable-scroll": true, "all-outputs": true @@ -25,12 +25,6 @@ "tooltip-format": "{:%Y-%m-%d | %H:%M}", "format-alt": "{:%Y-%m-%d}" }, - "cpu": { - "format": " {usage}%" - }, - "memory": { - "format": " {}%" - }, "backlight": { "format": "{icon} {percent}% ", "format-icons": ["", "", "", ""] @@ -43,15 +37,9 @@ "critical": 15 }, "format": " {capacity}%", - "format-discharging": "{icon} {capacity}%", + "format-discharging": "{icon} {capacity}%", "format-icons": ["", "", "", "", ""] }, - "network": { - "format-wifi": " {essid} ({signalStrength}%)", - "format-ethernet": "{ifname}: {ipaddr}/{cidr} ", - "format-disconnected": "⚠", - "on-click": "rofi-wifi-menu" - }, "pulseaudio": { "format": "{icon} {volume}%", "format-bluetooth": "{volume}% {icon}", @@ -78,5 +66,12 @@ "on-click": "playerctl play-pause", "escape": true, "exec": "$HOME/.config/waybar/custom_modules/mediaplayer.py 2> /dev/null" + }, + "custom/network": { + "escape" :true, + "exec": "$HOME/.config/waybar/custom_modules/wifi.sh 2> /dev/null", + "on-click": "rofi-wifi-menu", + "restart-interval": 1, + "return-type": "json" } } diff --git a/waybar/custom_modules/wifi.sh b/waybar/custom_modules/wifi.sh new file mode 100755 index 0000000..92d39ca --- /dev/null +++ b/waybar/custom_modules/wifi.sh @@ -0,0 +1,21 @@ +#! /usr/bin/env bash + +main(){ + connected_val="$(iwgetid 1> /dev/null ; echo $?)" + if [ $connected_val -eq 255 ]; then + echo '{"text": "⚠ Disconnected", "class":"disconnected"}' + return + else + wg_val="$(wg 2> /dev/null ; echo $?)" + if [ $wg_val -eq 0 ]; then + echo "{\"text\": \" $(iwgetid -r)\", \"class\":\"connected\"}" + else + echo "{\"text\": \"聯 $(iwgetid -r)\", \"class\":\"secured\"}" + fi + fi +} + +while true; do + main + sleep 1 +done