Add i3bar fields for OpenVPN.

This commit is contained in:
2015-11-20 19:03:00 +01:00
parent 43ffd1486c
commit b686a76588
4 changed files with 52 additions and 5 deletions

View File

@@ -1,5 +1,15 @@
separator_block_width=33
[vpn-main]
command=$HOME/.i3/scripts/openvpn main
label=
interval=120
[vpn-mgmt]
command=$HOME/.i3/scripts/openvpn mgmt
label=
interval=120
[wifi]
command=$HOME/.i3/scripts/wifi
label=
@@ -11,9 +21,9 @@ label=
interval=120
[load]
command=/usr/lib/i3blocks/load_average
command=$HOME/.i3/scripts/load
label=
interval=120
interval=30
[volume]
command=$HOME/.i3/scripts/pa-volume status

17
i3/i3/scripts/load Executable file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
load="$(cut -d ' ' -f 2 /proc/loadavg)"
cpus="$(nproc --all)"
echo $load
echo $load
awk -v cpus=$cpus -v _load=$load '
BEGIN {
if (_load >= cpus) {
print "#FF0000";
}
else if (_load >= cpus / 2) {
print "#FFFF00";
}
}'

20
i3/i3/scripts/openvpn Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env bash
[[ "$1" ]] || exit 1
name="$1"
pidfile="/run/openvpn@client-${name}.pid"
if pgrep --pidfile "${pidfile}" >/dev/null 2>&1 ; then
status="UP"
color="#ffffff"
else
status="DOWN"
color="#ff0000"
fi
output="${name} ${status}"
echo $output
echo $output
echo $color

View File

@@ -7,5 +7,5 @@ perc="$(echo $aps | cut -d ':' -f 3)"
output="$ssid $perc%"
echo $output
echo $output
echo "$output"
echo "$output"