From 821458758338d53e038b293082df32a51f0f3fba Mon Sep 17 00:00:00 2001 From: Niklas Date: Sun, 13 Sep 2020 14:00:51 +0200 Subject: [PATCH] added wireguard polybar stuff --- .config/polybar/90-polybar | 4 ++++ .config/polybar/config | 17 ++++++++++++++--- .config/polybar/wireguard-info.sh | 21 +++++++++++++++++++++ .config/polybar/wireguard-switch.sh | 20 ++++++++++++++++++++ 4 files changed, 59 insertions(+), 3 deletions(-) create mode 100755 .config/polybar/90-polybar create mode 100755 .config/polybar/wireguard-info.sh create mode 100755 .config/polybar/wireguard-switch.sh diff --git a/.config/polybar/90-polybar b/.config/polybar/90-polybar new file mode 100755 index 0000000..c40cd06 --- /dev/null +++ b/.config/polybar/90-polybar @@ -0,0 +1,4 @@ +#!/bin/sh +# copy to /etc/NetworkManager/dispatcher.d/90-polybar + +polybar-msg hook wireguard-status 1 diff --git a/.config/polybar/config b/.config/polybar/config index 4391bcf..a0b2621 100755 --- a/.config/polybar/config +++ b/.config/polybar/config @@ -26,6 +26,7 @@ height = 3% radius = 0 fixed-center = false + background = ${colors.background} foreground = ${colors.foreground} @@ -42,12 +43,11 @@ module-margin-left = 1 module-margin-right = 2 font-0 = fixed:pixelsize=10;1 -font-1 = unifont:fontformat=truetype:size=8:antialias=false;0 -font-2 = siji:pixelsize=10;1 +font-1 = "Hack Nerd Font:style=Regular:pixelsize=10;2" modules-left = i3 modules-center = -modules-right = spotifyd pulseaudio memory cpu wlan battery date +modules-right = spotifyd pulseaudio memory cpu wlan wireguard-status battery date tray-position = right tray-padding = 2 @@ -209,6 +209,17 @@ format-underline = #00b300 hook-0 = $HOME/.config/polybar/spotifyd-meta.sh initial = 1 +[module/wireguard-status] +type = custom/ipc + +format-foreground = ${colors.text} +format-underline = #00b300 + +click-left = $HOME/.config/polybar/wireguard-switch.sh + +hook-0 = $HOME/.config/polybar/wireguard-info.sh +initial = 1 + [settings] screenchange-reload = true ;compositing-background = xor diff --git a/.config/polybar/wireguard-info.sh b/.config/polybar/wireguard-info.sh new file mode 100755 index 0000000..f74f755 --- /dev/null +++ b/.config/polybar/wireguard-info.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env sh + +set -e + +ID_LIGHT="0f9ed364-1b54-4a95-a45a-a24114f5be6b" +ID_FULL="fa9f53b2-29b4-4c0e-80ca-38937ef8cad8" + +if nmcli connection show --active | grep "$ID_LIGHT" > /dev/null +then + echo -n  + exit 0 +fi + +if nmcli connection show --active | grep "$ID_FULL" > /dev/null +then + echo -n 聯 + exit 0 +fi + +echo -n 輦 + diff --git a/.config/polybar/wireguard-switch.sh b/.config/polybar/wireguard-switch.sh new file mode 100755 index 0000000..dad3847 --- /dev/null +++ b/.config/polybar/wireguard-switch.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env sh + +set -e + +ID_LIGHT="0f9ed364-1b54-4a95-a45a-a24114f5be6b" +ID_FULL="fa9f53b2-29b4-4c0e-80ca-38937ef8cad8" + +if nmcli connection show --active | grep "$ID_LIGHT" > /dev/null +then + nmcli connection up "$ID_FULL" + exit 0 +fi + +if nmcli connection show --active | grep "$ID_FULL" > /dev/null +then + nmcli connection up "$ID_LIGHT" + exit 0 +fi + +nmcli connection up "$ID_LIGHT"