dotfiles/dot_config/sketchybar/plugins/executable_mullvad.sh

21 lines
476 B
Bash
Raw Normal View History

2022-07-30 07:17:12 +02:00
#!/usr/bin/env bash
# path where mullvad is kept
PATH=/usr/local/bin:$PATH
if ! [ -x "$(command -v mullvad)" ]; then
sketchybar --set "$NAME" icon=" " label=""
fi
2022-07-30 07:17:12 +02:00
while read -r LINE; do
if echo "$LINE" | grep -q 'Connected'; then
# regex grep the relay, e.g. se7 for sweden-7
OUTPUT=$(echo "$LINE" | grep -oE "\w{2}\d+")
2022-07-30 07:17:12 +02:00
ICON=" "
else
ICON=" "
fi
sketchybar --set "$NAME" icon="$ICON" label="${OUTPUT^^}"
done < <(mullvad status listen)