Add wireguard module for polybar
This commit is contained in:
parent
e5e05bbe8a
commit
7603583d19
@ -80,7 +80,7 @@
|
||||
|
||||
modules-left = i3 bspwm xwindow
|
||||
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
|
||||
|
||||
@ -247,10 +247,9 @@
|
||||
interval = 2
|
||||
|
||||
format-prefix-foreground = ${colors.fg}
|
||||
|
||||
format-underline = ${colors.bg}
|
||||
|
||||
label = %{A1:$TERMINAL -e "htop" &:} %percentage:2%% %{A}
|
||||
label = %{A1:$TERMINAL -e "htop" &:} %percentage:2%%%{A}
|
||||
#+END_SRC
|
||||
|
||||
* Date
|
||||
@ -325,23 +324,6 @@
|
||||
ramp-capacity-2 =
|
||||
ramp-capacity-3 =
|
||||
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
|
||||
|
||||
* Temperature
|
||||
@ -663,6 +645,57 @@
|
||||
format-disconnected = <label-disconnected>
|
||||
#+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
|
||||
|
||||
#+BEGIN_SRC conf
|
||||
|
Loading…
Reference in New Issue
Block a user