I have blogged about ensuring you connect to a VPN when connecting to certain wi-fi networks. I have also blogged about connecting to a VPN when the computer boots. Both of those methods have merit, but also some inconveniences, like conflicting VPN profiles, or difficulty connecting on boot (before the password keyring for the VPN password is ready), etc.
I simplified my solution quite a bit, and I made it more resilient.
One of the things I said in my previous post I want a GNOME notification when not connected to VPN :
I would like to have a GNOME extension that pops a notification whenever I am not connected to a VPN.
Today I made that myself, and it was quite simple.
I started making a script that checks if there is a VPN network interface active. If not, then it uses notify-send
to
send a notification. Finally, I run that check every 5 minutes using cron.
How to do it
This is the script check-vpn-status.sh
:
1 |
|
I have seen that notify-send
sometimes does not show notifications when running from cron. I have seen that in
Ubuntu. If that is your case, try adding XDG_RUNTIME_DIR=/run/user/$(id -u)
at the end.
1 |
|
Then type crontab -e
to edit your cron jobs and add the following line:
1 |
|
Of course, you will need to change /home/e0ipso/.config
to the actual location of your script.
That’s it!
Photo by Misha Feshchak on Unsplash