At fifty, I am becoming the Linux nerd I feel I should have been at twenty-five.
I had a problem. I wanted an easy way to connect and disconnect from Diamond’s VPN. Yes, I could use the Network Connections interface in Linux Mint, but sometimes it expands while I was navigating to the VPN toggle and I accidentally attempt to connect to another WiFi network. Or, I could have set my VPN to autoconnect, as my WiFi does, except I don’t always need to be connected to the VPN. So, I wanted some sort of simple toggle–if the VPN is on, turn it off; if off, turn it on.
Could it be done with a script? I knew how — or, at least I had the commands in a documentation file I wrote for myself last year — to turn the VPN on or off from the command line. What I needed was a way to test the VPN’s status, then execute the right command based on that status.
First, with thanks to the Googles, I figured out how to determine if the VPN was active from the command line with the ifconfig command. Then I wrote an if statement off that command, plugged in the nmcli commands that activate/deactivate the VPN, and tested it.
It worked! On! Off! On! Off!
One little thing annoyed me. Activating the VPN popped up a notification that the VPN was active. Deactivating the VPN did not have a similar result. I discovered the notify-send command and created a deactivation notification.
I created a desktop file so I could call the script from my taskbar. I felt quite good. I had a problem, and I had solved it.
This morning, I decided I wanted to be able to activate and deactivate the VPN from my notifications instead. It makes sense; that’s where I look for my network status. So I would need a Cinnamon Applet.
I didn’t need anything fancy, just an icon I could click on and it executes the script. The Linux Mint website has some basic documentation for creating an applet, and I started from there. I took their samples, made a few edits, and gave it a try.
It didn’t work.
I have been careful not to turn on and turn off the VPN too rapidly, lest I lock myself out of the network.
The problem I had — a simple toggle to control my connection status with the work VPN — was solved.
No wonder I am “the problem project person” at work. See the problem, solve the problem.