polybar and wireguard utilities addition.

This commit is contained in:
2018-12-03 15:22:40 -02:00
parent 6224ae8e3e
commit 415a369096
3 changed files with 48 additions and 3 deletions

17
bin/wgX.sh Executable file
View File

@@ -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

View File

@@ -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

16
polybar/wg.sh Executable file
View File

@@ -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)";