refactor and adding custom wifi module.
This commit is contained in:
parent
4e5cb3baad
commit
50ef9fd177
|
@ -3,7 +3,7 @@
|
||||||
"height": 35,
|
"height": 35,
|
||||||
"modules-left": ["sway/workspaces", "sway/mode", "custom/media"],
|
"modules-left": ["sway/workspaces", "sway/mode", "custom/media"],
|
||||||
"modules-center": ["sway/window"],
|
"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": {
|
"sway/workspaces": {
|
||||||
"disable-scroll": true,
|
"disable-scroll": true,
|
||||||
"all-outputs": true
|
"all-outputs": true
|
||||||
|
@ -25,12 +25,6 @@
|
||||||
"tooltip-format": "{:%Y-%m-%d | %H:%M}",
|
"tooltip-format": "{:%Y-%m-%d | %H:%M}",
|
||||||
"format-alt": "{:%Y-%m-%d}"
|
"format-alt": "{:%Y-%m-%d}"
|
||||||
},
|
},
|
||||||
"cpu": {
|
|
||||||
"format": " {usage}%"
|
|
||||||
},
|
|
||||||
"memory": {
|
|
||||||
"format": " {}%"
|
|
||||||
},
|
|
||||||
"backlight": {
|
"backlight": {
|
||||||
"format": "{icon} {percent}% ",
|
"format": "{icon} {percent}% ",
|
||||||
"format-icons": ["", "", "", ""]
|
"format-icons": ["", "", "", ""]
|
||||||
|
@ -43,15 +37,9 @@
|
||||||
"critical": 15
|
"critical": 15
|
||||||
},
|
},
|
||||||
"format": " {capacity}%",
|
"format": " {capacity}%",
|
||||||
"format-discharging": "{icon} {capacity}%",
|
"format-discharging": "{icon} {capacity}%",
|
||||||
"format-icons": ["", "", "", "", ""]
|
"format-icons": ["", "", "", "", ""]
|
||||||
},
|
},
|
||||||
"network": {
|
|
||||||
"format-wifi": " {essid} ({signalStrength}%)",
|
|
||||||
"format-ethernet": "{ifname}: {ipaddr}/{cidr} ",
|
|
||||||
"format-disconnected": "⚠",
|
|
||||||
"on-click": "rofi-wifi-menu"
|
|
||||||
},
|
|
||||||
"pulseaudio": {
|
"pulseaudio": {
|
||||||
"format": "{icon} {volume}%",
|
"format": "{icon} {volume}%",
|
||||||
"format-bluetooth": "{volume}% {icon}",
|
"format-bluetooth": "{volume}% {icon}",
|
||||||
|
@ -78,5 +66,12 @@
|
||||||
"on-click": "playerctl play-pause",
|
"on-click": "playerctl play-pause",
|
||||||
"escape": true,
|
"escape": true,
|
||||||
"exec": "$HOME/.config/waybar/custom_modules/mediaplayer.py 2> /dev/null"
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
21
waybar/custom_modules/wifi.sh
Executable file
21
waybar/custom_modules/wifi.sh
Executable file
|
@ -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
|
Loading…
Reference in New Issue
Block a user