0

I am a linux beginner and I am trying to automate a small task on my computer. In order to connect to my vpn, I have to open my terminal and type nordvpn connect
I have created a simple .sh script that does this for me.

#!/bin/bash
nordvpn connect

The problem is that to run this file I have to open my terminal and write `./vpn.sh
Is there a way I can automate this to be done with a single click?

2 Answers2

3

Not sure about a click, but you could add a keyboard shortcut: Open Settings/Keyboard shortcuts, scroll to the bottom and press the plus sign. Give a name to your shortcut, enter /path/to/nordvpn connect as the command and then select a keyboard shortcut. Note: /path/to/nordvpn should be replaced by the output of which nordvpn.

Niclas Börlin
  • 1,946
  • 3
  • 20
  • 32
  • Hey that works great! Thank you. Is there any way to keep the terminal open or to have some other visual que that my vpn is running? – imstupidpleasehelp Jul 20 '21 at 20:53
  • I would post that as a separate question, but if you are on Ubuntu 20.04/default win mgr, you could start with wg-indicator (https://extensions.gnome.org/extension/2027/wg-indicator/) and modify ~/.local/share/gnome-shell/extensions/[email protected]/extension.js to look for whatever thing is active when nordvpn is active. I use the integrity.st vpn, and I use ["/bin/bash", "-c", "ip a | grep SEintegrity_vpn"] to check whether the vpn is active or not. – Niclas Börlin Jul 20 '21 at 22:24
2

To complement the very good alternative suggestion of Niclas Börlin to set up a shortcut key for this, I can add how the script can be set up to be run with a single mouse click, as originally asked.

You can create a .desktop launcher for the command. Such launcher will appear in your Application menu, from where you can pin it to the dock, providing one-click access.

vanadium
  • 82,909
  • 6
  • 116
  • 186