Score:0

Running .sh file with one button click

fr flag

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?

Paul avatar
us flag
I don't use Ubuntu desktop, but if there is a way to map keyboard shortcuts to commands, that might work.
imstupidpleasehelp avatar
fr flag
I'm pretty sure its possible. I've found several similar questions on this forum but most are from 10 years ago
Score:3
fr flag

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.

imstupidpleasehelp avatar
fr flag
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?
fr flag
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.
Score:2
cn flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.