2022-03-18 09:55:44 +01:00
|
|
|
diff --git a/polybar-wireguard b/polybar-wireguard
|
2022-03-25 17:10:57 +01:00
|
|
|
deleted file mode 100755
|
|
|
|
index 6712185..0000000
|
2022-03-18 09:55:44 +01:00
|
|
|
--- a/polybar-wireguard
|
2022-03-25 17:10:57 +01:00
|
|
|
+++ /dev/null
|
|
|
|
@@ -1,58 +0,0 @@
|
|
|
|
-#!/usr/bin/env sh
|
|
|
|
-
|
|
|
|
-# Unfortunately it's not easy to directly use Polybar colour values in this
|
|
|
|
-# script so I have to redefine some of my colours here. See the link below for
|
|
|
|
-# more details:
|
|
|
|
-# https://github.com/polybar/polybar/wiki/Formatting#format-tags-inside-polybar-config
|
|
|
|
-green=#55aa55
|
|
|
|
-
|
2022-03-18 09:55:44 +01:00
|
|
|
-configs_path="/PATH/TO/CONF/FILES"
|
2022-03-25 17:10:57 +01:00
|
|
|
-connected_interface=$(sudo wg | grep interface | cut -d " " -f2)
|
|
|
|
-
|
|
|
|
-connect() {
|
2022-03-18 09:55:44 +01:00
|
|
|
- selected_config=$(ls $configs_path/*.conf | xargs basename -a -s .conf | dmenu)
|
2022-03-25 17:10:57 +01:00
|
|
|
- [[ $selected_config ]] && sudo wg-quick up "$configs_path"/"$selected_config".conf
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-disconnect() {
|
|
|
|
- # Normally we should have a single connected interface but technically
|
|
|
|
- # there's nothing stopping us from having multiple active intgerfaces so
|
|
|
|
- # let's do this in a loop:
|
|
|
|
- for connected_config in $(sudo wg | grep interface | cut -d " " -f2)
|
|
|
|
- do
|
|
|
|
- sudo wg-quick down $configs_path/"$connected_config".conf
|
|
|
|
- done
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-toggle() {
|
|
|
|
- if [[ $connected_interface ]]
|
|
|
|
- then
|
|
|
|
- disconnect
|
|
|
|
- else
|
|
|
|
- connect
|
|
|
|
- fi
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-print() {
|
|
|
|
- if [[ $connected_interface ]]
|
|
|
|
- then
|
|
|
|
- echo %{u"$green"}%{+u}%{T4}%{F"$green"}%{T-}%{F-} "$connected_interface"
|
|
|
|
- else
|
|
|
|
- echo %{T4}%{T-}
|
|
|
|
- fi
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-case "$1" in
|
|
|
|
- --connect)
|
|
|
|
- connect
|
|
|
|
- ;;
|
|
|
|
- --disconnect)
|
|
|
|
- disconnect
|
|
|
|
- ;;
|
|
|
|
- --toggle)
|
|
|
|
- toggle
|
|
|
|
- ;;
|
|
|
|
- *)
|
|
|
|
- print
|
|
|
|
- ;;
|
|
|
|
-esac
|