Skip to content

Hiding VPN Icon When There is No VPN #3931

Answered by mabourehab
mabourehab asked this question in Q&A
Discussion options

You must be logged in to vote

I was able to do a workaround by writing the actual check for the VPN in the script, then returning an empty text object if it's not there:

~/.config/waybar/scripts/vpn.sh

if [ -d /proc/sys/net/ipv4/conf/vpn0 ]; then
  testlink=$(ip link show type tun | grep -E ' UP ')
  if [ "$?" = 0 ]; then
    status='{"text": "VPN On"}'
  else
    status='{"text": "VPN Off"}'
  fi
else
  status='{"text": ""}'
fi

echo $status

~/.config/waybar/config-jsonc

  "custom/vpn": {
    "restart-interval": 3,
    "format": "{}",
    "hide-empty-text": true,
    "exec": "~/.config/waybar/scripts/vpn.sh",
    "return-type": "json",
    "on-click": "nmcli connection up 'VPN'  &>/dev/null &",
    "on-click-right":…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mabourehab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant