Add wireguard module for polybar
This commit is contained in:
		@@ -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
 | 
			
		||||
@@ -311,10 +310,10 @@
 | 
			
		||||
  adapter = AC
 | 
			
		||||
  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-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}
 | 
			
		||||
 | 
			
		||||
  label-full = %{A1:xfce4-power-manager-settings &:} %{A}
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user