Add wireguard module for polybar
This commit is contained in:
parent
e5e05bbe8a
commit
7603583d19
@ -80,7 +80,7 @@
|
|||||||
|
|
||||||
modules-left = i3 bspwm xwindow
|
modules-left = i3 bspwm xwindow
|
||||||
modules-center =
|
modules-center =
|
||||||
modules-right = pulseaudio xbacklight redshift nordvpn lockscreen dunst packages unread_mail cpu battery temperature date
|
modules-right = pulseaudio xbacklight redshift wireguard nordvpn lockscreen dunst packages unread_mail temperature battery date
|
||||||
|
|
||||||
wm-restack = i3
|
wm-restack = i3
|
||||||
|
|
||||||
@ -247,10 +247,9 @@
|
|||||||
interval = 2
|
interval = 2
|
||||||
|
|
||||||
format-prefix-foreground = ${colors.fg}
|
format-prefix-foreground = ${colors.fg}
|
||||||
|
|
||||||
format-underline = ${colors.bg}
|
format-underline = ${colors.bg}
|
||||||
|
|
||||||
label = %{A1:$TERMINAL -e "htop" &:} %percentage:2%% %{A}
|
label = %{A1:$TERMINAL -e "htop" &:} %percentage:2%%%{A}
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
* Date
|
* Date
|
||||||
@ -311,10 +310,10 @@
|
|||||||
adapter = AC
|
adapter = AC
|
||||||
full-at = 95
|
full-at = 95
|
||||||
|
|
||||||
format-charging = %{A1:xfce4-power-manager-settings &:}<ramp-capacity> <label-charging>%{A}
|
format-charging = %{A1:xfce4-power-manager-settings &:}<ramp-capacity> <label-charging>%{A}
|
||||||
format-charging-underline = ${colors.blue}
|
format-charging-underline = ${colors.blue}
|
||||||
|
|
||||||
format-discharging = %{A1:xfce4-power-manager-settings &:}<ramp-capacity> <label-discharging>%{A}
|
format-discharging = %{A1:xfce4-power-manager-settings &:}<ramp-capacity> <label-discharging>%{A}
|
||||||
format-discharging-underline = ${colors.red}
|
format-discharging-underline = ${colors.red}
|
||||||
|
|
||||||
label-full = %{A1:xfce4-power-manager-settings &:} %{A}
|
label-full = %{A1:xfce4-power-manager-settings &:} %{A}
|
||||||
@ -325,23 +324,6 @@
|
|||||||
ramp-capacity-2 =
|
ramp-capacity-2 =
|
||||||
ramp-capacity-3 =
|
ramp-capacity-3 =
|
||||||
ramp-capacity-4 =
|
ramp-capacity-4 =
|
||||||
ramp-capacity-foreground = ${colors.fg}
|
|
||||||
|
|
||||||
animation-charging-0 =
|
|
||||||
animation-charging-1 =
|
|
||||||
animation-charging-2 =
|
|
||||||
animation-charging-3 =
|
|
||||||
animation-charging-4 =
|
|
||||||
animation-charging-foreground = ${colors.fg}
|
|
||||||
animation-charging-framerate = 750
|
|
||||||
|
|
||||||
animation-discharging-0 =
|
|
||||||
animation-discharging-1 =
|
|
||||||
animation-discharging-2 =
|
|
||||||
animation-discharging-3 =
|
|
||||||
animation-discharging-4 =
|
|
||||||
animation-discharging-foreground = ${color.fg}
|
|
||||||
animation-discharging-framerate = 750
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
* Temperature
|
* Temperature
|
||||||
@ -663,6 +645,57 @@
|
|||||||
format-disconnected = <label-disconnected>
|
format-disconnected = <label-disconnected>
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
* Wireguard
|
||||||
|
#+BEGIN_SRC conf
|
||||||
|
[module/wireguard]
|
||||||
|
type = custom/script
|
||||||
|
|
||||||
|
format-underline = ${colors.bg}
|
||||||
|
click-left = ~/.config/polybar/scripts/wireguard-toggle.sh
|
||||||
|
format = <label>
|
||||||
|
exec = ~/.config/polybar/scripts/wireguard-status.sh
|
||||||
|
|
||||||
|
interval = 2
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Wireguard Connection Status
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args: :tangle ~/.config/polybar/scripts/wireguard-status.sh
|
||||||
|
:header-args+: :comments both :mkdirp yes
|
||||||
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||||
|
:END:
|
||||||
|
|
||||||
|
#+begin_src bash
|
||||||
|
config="pivpn"
|
||||||
|
|
||||||
|
connection=$(sudo wg show "$config" 2>/dev/null | head -n 1 | awk '{print $NF }')
|
||||||
|
|
||||||
|
if [ "$connection" = "$config" ]; then
|
||||||
|
echo "%{F#859900} $config%{F-}"
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** Toggle Wireguard Connection
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args: :tangle ~/.config/polybar/scripts/wireguard-toggle.sh
|
||||||
|
:header-args+: :comments both :mkdirp yes
|
||||||
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||||
|
:END:
|
||||||
|
|
||||||
|
#+begin_src bash
|
||||||
|
config="pivpn"
|
||||||
|
|
||||||
|
connection=$(sudo wg show "$config" 2>/dev/null | head -n 1 | awk '{print $NF }')
|
||||||
|
|
||||||
|
if [ "$connection" = "$config" ]; then
|
||||||
|
sudo wg-quick down "$config" && dunstify --replace=83244 "Wireguard" "Disconnected from $config"
|
||||||
|
else
|
||||||
|
sudo wg-quick up "$config" && dunstify --replace=83244 "Wireguard" "Connected to $config"
|
||||||
|
fi
|
||||||
|
#+end_src
|
||||||
|
|
||||||
* Screenshot
|
* Screenshot
|
||||||
|
|
||||||
#+BEGIN_SRC conf
|
#+BEGIN_SRC conf
|
||||||
|
Loading…
Reference in New Issue
Block a user