diff --git a/bin/wgX.sh b/bin/wgX.sh new file mode 100755 index 0000000..4051ab2 --- /dev/null +++ b/bin/wgX.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +verb=$1 + +iface=$(basename $0) + +if [ -z "$verb" ]; then + verb=status; +fi + +if [ "$verb" = "up" ] || [ "$verb" = "down" ]; then + sudo wg-quick $verb /etc/wireguard/${iface}.conf; +fi + +if [ "$verb" = "status" ] || [ "$verb" = "start" ] || [ "$verb" = "stop" ]; then + sudo systemctl $verb wg-quick@${iface}.service; +fi diff --git a/polybar/config b/polybar/config index 8da5b3c..d06c678 100644 --- a/polybar/config +++ b/polybar/config @@ -63,7 +63,7 @@ font-6 = siji:pixelsize=9;1 modules-left = bspwm i3 xwindow ;modules-left = i3 modules-center = mpd -modules-right = filesystem backlight volume xkeyboard memory cpu eth wlan wg0 wg1 temperature battery date powermenu +modules-right = filesystem backlight volume xkeyboard memory cpu eth wlan wg temperature battery date powermenu tray-position = right tray-padding = 2 @@ -134,9 +134,10 @@ interval = 25 mount-0 = / mount-1 = /home -mount-2 = /home/renato/cloud.renatorosa.com -mount-3 = /home/renato/drive.silveirarosa.com +#mount-2 = /media/renato/cloud.renatorosa.com +#mount-3 = /media/renato/cloud.silveirarosa.com +#label-mounted = %fsname%:%{F#0a81f5}%mountpoint%%{F-}: %percentage_used%% label-mounted = %{F#0a81f5}%mountpoint%%{F-}: %percentage_used%% label-unmounted = (N/A) label-unmounted-foreground = ${colors.foreground-alt} @@ -372,6 +373,13 @@ format-disconnected-underline = ${self.format-connected-underline} label-disconnected = %ifname% label-disconnected-foreground = ${colors.foreground-alt} +[module/wg] +type = custom/script +exec = ~/src/sysadmin/polybar/wg.sh +interval = 5 +# tail = true + + [module/wg0] inherit = module/eth interface = wg0 @@ -520,6 +528,10 @@ animation-charging-2 =  animation-charging-foreground = ${colors.foreground-alt} animation-charging-framerate = 750 +label-charging = %percentage%% (%time%) +label-discharging = %percentage%% (%time%) +label-full = FULL + [module/battery-alt] type = internal/battery battery = BAT0 diff --git a/polybar/wg.sh b/polybar/wg.sh new file mode 100755 index 0000000..084293f --- /dev/null +++ b/polybar/wg.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +#printf "wg:" && (pgrep -a $(sudo wg)$ | head -n 1 | awk '{print $NF'} | cut -d '.' -f 1 && echo down) | head -n 1 + +wg=$(sudo wg); + +if [ -z "$wg" ]; then + echo "(down)"; + exit 0; +fi + +handshake=$(echo "$wg" | grep handshake | cut -d ':' -f 2 | sed 's/minutes/min/' | sed 's/seconds/sec/'); + +transfer=$(echo "$wg" | grep transfer | cut -d ':' -f 2 | sed 's/sent/UL/' | sed 's/received,/DL/' | sed 's/iB//g') ; + +printf "wg:$transfer($handshake)";