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.
18 lines
365 B
Bash
Executable File
18 lines
365 B
Bash
Executable File
#!/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
|