polybar: Make hardcoded paths dependant from XDG

Instead of hardcoding the paths of all the scripts, use env variables
that are set in launch.sh. This way the config also works with
XDG_CONFIG_HOME not set to ~/.config.
Sadly polybar only accepts references that stand on their own.
(So something like ${env:XDG_CONFIG_HOME:~/.config}/polybar/<script>
does not work.) Hence the mess with the associative array and the
variables for every module.
This commit is contained in:
2020-09-28 18:08:03 +02:00
parent abf4ad7333
commit 1d3adc30e5
4 changed files with 26 additions and 9 deletions

17
.config/polybar/scripts/vpn.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/sh
connection="$(nmcli con show --active | awk '$3 ~ /^(vpn|tun)$/ { print $1 }')"
if [ -n "$connection" ]; then
echo "VPN: $connection"
exit 0
fi
# [o] is a hack to not grep the grep-command
# see: https://stackoverflow.com/questions/9375711/more-elegant-ps-aux-grep-v-grep
if ps ax | grep -q "[o]penvpn"; then
echo "VPN"
exit 0
fi
echo
exit 1