Improved polybar to include wireguard switch

main
Guus van Meerveld 2 years ago
parent b75ad20729
commit ba536feee5
Signed by: Guusvanmeerveld
GPG Key ID: 2BA7D7912771966E

@ -38,8 +38,8 @@ height = 40
monitor = ${env:MONITOR:} monitor = ${env:MONITOR:}
font-0 = Roboto:pixelsize=13;1 font-0 = Roboto:pixelsize=13;1
font-1 = Material Icons:pixelsize=15;4 font-1 = Material Icons:pixelsize=15;3
font-2 = Roboto Mono:pixelsize=13;1 font-2 = MesloLGS NF:pixelsize=10;1
separator = "|" separator = "|"
separator-padding = 1 separator-padding = 1
@ -60,7 +60,7 @@ module-margin-left = 2
modules-left = bspwm modules-left = bspwm
modules-center = title modules-center = title
modules-right = phone-battery temperature memory cpu battery wlan eth date modules-right = phone-battery temperature memory cpu audio battery wireguard wlan eth date
wm-restack = bspwm wm-restack = bspwm

@ -6,17 +6,23 @@ full-at = 100
format-charging = <label-charging> format-charging = <label-charging>
format-discharging = <ramp-capacity> <label-discharging> format-discharging = <ramp-capacity> <label-discharging>
label-charging = %percentage%% label-charging = %percentage%%
label-discharging = %percentage%% label-discharging = %percentage%%
ramp-capacity-0 =  ramp-capacity-0 = 
ramp-capacity-1 =  ramp-capacity-1 = 
ramp-capacity-2 =  ramp-capacity-2 = 
ramp-capacity-3 =  ramp-capacity-3 = 
ramp-capacity-4 =  ramp-capacity-4 = 
ramp-capacity-5 = 
ramp-capacity-6 = 
ramp-capacity-7 = 
ramp-capacity-8 = 
ramp-capacity-9 = 
ramp-capacity-10 = 
[module/title] [module/title]
type = internal/xwindow type = internal/xwindow
@ -47,22 +53,31 @@ format-disconnected = <label-disconnected>
label-disconnected =  label-disconnected = 
[module/wireguard]
type = custom/script
exec = ~/.config/polybar/wireguard-is-connected.sh
click-left = ~/.config/polybar/toggle-wireguard.sh
interval = 5
[module/eth] [module/eth]
type = internal/network type = internal/network
interface = enp34s0 interface = enp34s0
interval = 3.0 interval = 3.0
label-connected =  %downspeed% label-connected = %downspeed%
format-connected = <label-connected> format-connected = <label-connected>
label-disconnected = label-disconnected =
[module/phone-battery] [module/phone-battery]
type = custom/script type = custom/script
exec = echo "$(mconnectctl show-battery /org/mconnect/device/0 | head -1 | awk '{print $2}')%" exec = echo "$(mconnectctl show-battery /org/mconnect/device/0 | head -1 | awk '{print $2}')%"
exec-if = ~/.config/polybar/phone-is-connected.sh exec-if = ~/.config/polybar/phone-is-connected.sh
@ -78,4 +93,4 @@ date = %a %e %b
label = %date% %time% label = %date% %time%
format = <label> format = <label>

@ -2,7 +2,8 @@
type = internal/xbacklight type = internal/xbacklight
format = <label> <bar> format = <label> <bar>
label = BL
label = %percentage%
bar-width = 10 bar-width = 10
bar-indicator = | bar-indicator = |
@ -15,13 +16,8 @@ bar-empty = ─
bar-empty-font = 2 bar-empty-font = 2
bar-empty-foreground = ${colors.foreground-alt} bar-empty-foreground = ${colors.foreground-alt}
[module/backlight-acpi] [module/audio]
inherit = module/backlight type = internal/pulseaudio
type = internal/backlight
card = intel_backlight
[module/alsa]
type = internal/alsa
format-muted =  format-muted = 
@ -44,6 +40,8 @@ bar-volume-fill-font = 1
bar-volume-empty = ─ bar-volume-empty = ─
bar-volume-empty-font = 1 bar-volume-empty-font = 1
click-right = pavucontrol
[module/cpu] [module/cpu]
type = internal/cpu type = internal/cpu
interval = 2 interval = 2

@ -0,0 +1,10 @@
#!/bin/bash
connection="wg0"
connected="$(nmcli -f GENERAL.STATE con show $connection | awk '{print $2}')"
if [[ $connected == "activated" ]]; then
nmcli connection down $connection
else
nmcli connection up $connection
fi

@ -0,0 +1,10 @@
#!/bin/bash
connection="wg0"
connected="$(nmcli -f GENERAL.STATE con show $connection | awk '{print $2}')"
if [[ $connected == "activated" ]]; then
echo ""
else
echo ""
fi