NORD VPN - Simple GUI

Chat about anything related to Linux Mint
Forum rules
Do not post support questions here. Before you post read the forum rules. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
rossdv8
Level 7
Level 7
Posts: 1737
Joined: Wed Apr 23, 2014 4:48 am
Location: Within 2,000 kilometres of Alice Springs, Australia
Contact:

NORD VPN - Simple GUI

Post by rossdv8 »

NOTE - This is not a 'How To' tutorial.
I did this as an experiment because various people have tried Nord and complained that it doesn;t have GUI Linux App (it is Terminal Only).

It works for me, and I'd be interested to hear if anyone with Nord finds it easy or useful.
Nord has a whole page of commands to connect to and query stuff. I've only connected buttons to the most often used commands. It is dead easy to add whatever other bash commands you would use most often.

U P D A T E:
RiptideC Has made some changes to my little GUI that make it work better with 'normal' Mint desktops. You might notice in my original scripts my Terminal is konsole. Changing that is only one of several differences.
There is a better description in this viewtopic.php?p=2129961#p2129961 reply and also a link to the code which is now posted on GitHub :-)

***
My original post starts below:

I recently had a reason to try out Nord VPN and found that it works better than PIA (at January 2022) for some streaming sites like Amazon Prime Video. I posted the Zenity code for a simple GUI, but it is lost in another post about VPN recommendations, so I thought I might post it here for anyone who is trying Nord VPN and is frustrated by the Terminal Only app for Linux.

I know there are some really nice looking Python GUIs out there on GitHub, and I have tried a couple of them. All they did (well, the only one that 'seemed' to start) was screw up my configuration.

So, while this script is 'quick and dirty', it has everything set up one step at a time, starting Left to Right, and the main options in order to open and close.

It uses 'Zenity' which should be already installed (sudo apt install zenity).

Pressing LogIn will open a Terminal and after a moment a Hylerlink should appear.
Right click on the link and choose Open
Your default Browser should open at a Login screen for NordVPN and ask for your credentials.
Once it has verified you, it will tell you and a link will show below the login details saying 'Return to the App'. Click the link and it might take you back to the terminal.
That's the most complicated part of the whole provedure.

At present there's NO List of Servers or Countries. Pressing 'Connect' on the GUI should automatically connect you to the nearest / closest NordVPN server in your country.

The Status button is just to see if you are logged in or connected. The Check button is to see what options you have active at the moment. It and the Status button can be pressed at any time to see what is running)
I set Check after the DNS button because I wanted to see if DNS was set before I actually connect.

Clicking the DNS button lets you enable a DNS (I am using Cloudflare - but you can set it easily to Google or whatever the 4 x 9 one is).

Whenever you choose a button, a Terminal window should open and display the result of that action.
Whenever you close a Terminal window the GUI should come up again.

Pressing the QUIT button closes the GUI, but does NOT (or at least it should not) kill your VPN connection. To do that you should choose DISconnect, followed by Log Out - then Quit to close the App.

That's why it is 'Quick and Dirty'. It is easy enough to add some more options - I just haven't needed them.

The first bit of code is a .desktop file. Save it in /home/Desktop, and give it an Icon you can see easily. Put in in your Panel and click on it to open the GUI.

Here's what it looks like today (Jan 21 2022):
The Zenity GUI as it opens:

Image

After the Check button is pressed - showing the options I have selected. If I had pressed the Kill Switch Button, it would show as ON. (Closing this Terminal returns to the GUI):

Image

Because it has changed a bit since I posted it in the other thread - Later today or maybe tomorrow I will add the code (again) below for:

NordVPN.desktop

Code: Select all

[Desktop Entry]
Comment[en_AU]=
Comment=
Exec="bash /home/ross/Desktop/Shell-Scripts/NordVPN/nordvpn.sh"  %U
GenericName[en_AU]=
GenericName=
Icon=/home/ross/Custom_Icons/vpn-png.png
MimeType=
Name[en_AU]=NordVPN-ZENITY
Name=NordVPN-ZENITY
Path=
StartupNotify=true
Terminal=true
TerminalOptions=\s--noclose
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=
the GUI itself:

nordvpn.sh
Copied

Code: Select all

#!/bin/bash
#
# nordvpn.sh - BASIC NordVPN GUI (Zenity)
#
# to use the GUI;  Open a Terminal in the Folder that holds    nordvpn.sh
#            run:   bash nordvpn.sh
# 
#LEAVE the Terminal Window or windows OPEN (ALL of them !!!) until you log out
# with any luck it should just be your ORIGINAL Terminal opened in the folder with the file
#
# Work in this order:  Status (Check) - LogIn - Connect - KillSwith ON - KillSwitch OFF -DISconnect - LogOut
#  Added Kill Switch Buttons because sometimes the computer had to be rebooted to reset it.
# (this NordVPN Zenity is modified from something I saw running a PiBot)

rc=1 # OK button return code =0 , all others =1
while [ $rc -eq 1 ]; do
  ans=$(zenity --info --title 'NordVPN' \
      --ok-label Quit \
      --extra-button Status \
      --extra-button LOGIN \
      --extra-button DNS \
      --extra-button CHECK \
      --extra-button Connect \
	  --extra-button Kill-Sw-ON \
	  --extra-button Kill-Sw-OFF \
      --extra-button DISconnect \
      --extra-button LogOUT \
      --extra-button Spare \

       )
  rc=$?
  echo "${rc}-${ans}"
  echo $ans
  if [[ $ans = "Status" ]]
  then 
        konsole --noclose -e /usr/bin/nordvpn status;

  elif [[ $ans = "LOGIN" ]]
  then
       konsole --noclose -e /usr/bin/nordvpn login %U;
    elif [[ $ans = "DNS" ]]
  then
       konsole --noclose -e /usr/bin/nordvpn set dns 1.1.1.1 1.0.0.1;
  elif [[ $ans = "Connect" ]]
  then
        konsole --noclose -e /usr/bin/nordvpn connect;
        elif [[ $ans = "CHECK" ]]
  then
       konsole --noclose -e /usr/bin/nordvpn settings %U;
  elif [[ $ans = "Kill-Sw-ON" ]]
  then  
        konsole --noclose -e /usr/bin/nordvpn set killswitch on;
  elif [[ $ans = "Kill-Sw-OFF" ]]
  then
        konsole --noclose -e /usr/bin/nordvpn set killswitch off;
elif [[ $ans = "DISconnect" ]]
  then
        konsole --noclose -e /usr/bin/nordvpn disconnect;
 elif [[ $ans = "LogOUT" ]]
  then
        konsole --noclose -e /usr/bin/nordvpn logout;

  fi
done
and where I keep the scripts:

I keep these scripts in:
/home/ross/Desktop/Shell-Scripts/NordVPN/

But as long as the paths work, you could keep them just about anywhere.
I find it is just easier to keep the .desktop file in the same directory as nordvpn.sh (makes it easier to run if both files are in the same place).

It would probably make sense to put the Icon in there too.
I have a /home/Custom-Icons folder, but I do a LOT of scripts that use a .desktop file to start them - so for me I have all my icons together.
Just make sure the path in the NordVPN.desktop file points to where the icon IS.

There are some nice icons to download in DuckDuckGo images or Giggle Images.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 4 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Current main OS: MInt 21.3 with KDE Plasma 5.27 (using Compiz as WM) - Kernel: 6.5.0-15 on Lenovo m900 Tiny, i5-6400T (intel HD 530 graphics) 16GB RAM.
Sharks usually only attack you if you are wet
User avatar
GELvdH
Level 5
Level 5
Posts: 977
Joined: Tue Jan 08, 2019 10:10 am
Location: 3rd rock from Sun

Re: NORD VPN - Simple GUI

Post by GELvdH »

I have been using NordVPN for a couple of years and have gotten used to the terminal command line. There are only about 1/2 dozen commands to set it up. Once you have it set up there is no reason to change any thing so I don't see a reason to install a GUI.
User avatar
rossdv8
Level 7
Level 7
Posts: 1737
Joined: Wed Apr 23, 2014 4:48 am
Location: Within 2,000 kilometres of Alice Springs, Australia
Contact:

Re: NORD VPN - Simple GUI

Post by rossdv8 »

I owe the board an apology for trying to manually move this from 'Networking' to a more general 'Chat' area!

Sorry :oops:
Current main OS: MInt 21.3 with KDE Plasma 5.27 (using Compiz as WM) - Kernel: 6.5.0-15 on Lenovo m900 Tiny, i5-6400T (intel HD 530 graphics) 16GB RAM.
Sharks usually only attack you if you are wet
RiptideC
Level 1
Level 1
Posts: 4
Joined: Tue Jan 25, 2022 9:33 pm

Re: NORD VPN - Simple GUI

Post by RiptideC »

Hi rossdv8! How are you?

Thank you for your initiative and for sharing your work!

I took the liberty of making some changes to your scripts to make them more adherent to Cinnamon Desktop (I hope you do not mind...)

File: NordVPN.desktop

Code: Select all

[Desktop Entry]
Type=Application
Name=NordVPN-ZENITY
Icon=nordvpn
MimeType=x-scheme-handler/nordvpn
Exec="path/to/nordvpn.sh" %U
Terminal=true
File: nordvpn.sh

Code: Select all

#!/bin/bash

# nordvpn.sh - BASIC NordVPN GUI (Zenity)
#
# to use the GUI;  Open a Terminal in the Folder that holds    nordvpn.sh
#            run:   bash nordvpn.sh
# 
#LEAVE the Terminal Window or windows OPEN (ALL of them !!!) until you log out
# with any luck it should just be your ORIGINAL Terminal opened in the folder with the file
#
# Work in this order:  Status (Check) - LogIn - Connect - KillSwith ON - KillSwitch OFF -DISconnect - LogOut
#  Added Kill Switch Buttons because sometimes the computer had to be rebooted to reset it.
# (this NordVPN Zenity is modified from something I saw running a PiBot)

PATHNORD=/usr/bin/nordvpn

rc=1 # OK button return code =0 , all others =1
while [ $rc -eq 1 ]; do
  ans=$(zenity --info --title 'NordVPN' \
      --ok-label Quit \
      --extra-button Status \
      --extra-button LOGIN \
      --extra-button DNS \
      --extra-button CHECK \
      --extra-button Connect \
	  --extra-button Kill-Sw-ON \
	  --extra-button Kill-Sw-OFF \
      --extra-button DISconnect \
      --extra-button LogOUT \
      --extra-button Spare \

       )
  rc=$?
  echo "${rc}-${ans}"
  echo $ans
  if [[ $ans = "Status" ]]
  then 
        gnome-terminal --tab -- bash -c "$PATHNORD status;"

  elif [[ $ans = "LOGIN" ]]
  then
       gnome-terminal --tab -- bash -c "$PATHNORD login %U;"
    elif [[ $ans = "DNS" ]]
  then
       gnome-terminal --tab -- bash -c "$PATHNORD set dns 1.1.1.1 1.0.0.1;"
  elif [[ $ans = "Connect" ]]
  then
        gnome-terminal --tab -- bash -c "$PATHNORD connect;"
        elif [[ $ans = "CHECK" ]]
  then
       gnome-terminal --tab -- bash -c "$PATHNORD settings %U;"
  elif [[ $ans = "Kill-Sw-ON" ]]
  then  
        gnome-terminal --tab -- bash -c "$PATHNORD set killswitch on;"
  elif [[ $ans = "Kill-Sw-OFF" ]]
  then
        gnome-terminal --tab -- bash -c "$PATHNORD set killswitch off;"
elif [[ $ans = "DISconnect" ]]
  then
        gnome-terminal --tab -- bash -c "$PATHNORD disconnect;"
 elif [[ $ans = "LogOUT" ]]
  then
        gnome-terminal --tab -- bash -c "$PATHNORD logout;"

  fi
done
Have you ever thought about creating a git repository for your code?

I believe it would be interesting.

By the way... Really nice job!
User avatar
rossdv8
Level 7
Level 7
Posts: 1737
Joined: Wed Apr 23, 2014 4:48 am
Location: Within 2,000 kilometres of Alice Springs, Australia
Contact:

Re: NORD VPN - Simple GUI

Post by rossdv8 »

Thank you for the nice comments :-)

I certainly do not mind if you change it and share it.
I no longer write what most people would call 'real' code since my last lot of brain injuries, but I do still do little things when I see a need, and Bash is my weapon of choice for quickies, with Zenity if I want to make something with buttons. Like my selector for running Video Wallpaper on Xfce (and probably Cinnamon and Mate). That is also using Zenity.

There are a couple of Python scripts floating around Git that are supposed to work with Nord, but I only see an occasional comment about one working and mostly comments are that they don't - which was the case when I tried one.

Since the Nord 'app for Linux' runs only by use of Terminal commands, and some people were still commenting that it would be nice to have GUI, I thought Zenity might come to the rescue.
I posted here (actually I posted in the section where I saw the initial post about someone wanting to leave Nord - partly because of the lack of a GUI - and got into a little warm water :oops: ) so anyone who liked the idea could indeed try it, fix anything they didn;t like or which didn't work for them, perhaps make it better and share the result.

I use only Mint Xfce these days, and even my Xfce is more like KDE than Xfce, so I'm not surprised it doesn;t work properlyon Cinnamon's Desktop.

But it is a starting point, and if you make it work on Cinnamon, and someone makes it work on Mate - we're all laughing :D
Current main OS: MInt 21.3 with KDE Plasma 5.27 (using Compiz as WM) - Kernel: 6.5.0-15 on Lenovo m900 Tiny, i5-6400T (intel HD 530 graphics) 16GB RAM.
Sharks usually only attack you if you are wet
RiptideC
Level 1
Level 1
Posts: 4
Joined: Tue Jan 25, 2022 9:33 pm

Re: NORD VPN - Simple GUI

Post by RiptideC »

Hi rossdv8!

Definitely I'm not a developer or coder... LoL

But after a lot of research and testing I managed to use github and uploaded the initial version to Cinnamon Desktop (hopefully it will work on any Debian based distro with "gnome-terminal" installed).

The repo address is: https://github.com/romfetchr/nordvpn-zenity

Some simple "enhancements" I've made:

Image

Image

Image

Best Regards!
User avatar
rossdv8
Level 7
Level 7
Posts: 1737
Joined: Wed Apr 23, 2014 4:48 am
Location: Within 2,000 kilometres of Alice Springs, Australia
Contact:

Re: NORD VPN - Simple GUI

Post by rossdv8 »

Clever idea adding the 'do not close me'. I went the other way and made the thing default to the GUI every time the terminal was closed - but that might not work with a Mint terminal (as you use in normal Mint desktops). I use Konsole, which is a Plasma program, because, well, my Mint Xfce thinks it is almost Plasma. In my original I have to use the QUIT button or the thing just keeps opening the GUI each time we close the Terminal.

Your change keeps the terminal open and also makes it simple to see the result of the action = such a simple thing but much more thought out than my hasty mess.

I like that you made that change. Thanks.

I'll edit my first post to add a quote with your update :D

D O N E !!
Current main OS: MInt 21.3 with KDE Plasma 5.27 (using Compiz as WM) - Kernel: 6.5.0-15 on Lenovo m900 Tiny, i5-6400T (intel HD 530 graphics) 16GB RAM.
Sharks usually only attack you if you are wet
RiptideC
Level 1
Level 1
Posts: 4
Joined: Tue Jan 25, 2022 9:33 pm

Re: NORD VPN - Simple GUI

Post by RiptideC »

Hi rossdv8! How are you?
rossdv8 wrote: Mon Jan 24, 2022 11:49 pm U P D A T E:
RiptideC Has made some changes to my little GUI that make it work better with 'normal' Mint desktops. You might notice in my original scripts my Terminal is konsole. Changing that is only one of several differences.
There is a better description in this viewtopic.php?p=2129961#p2129961 reply and also a link to the code which is now posted on GitHub :-)
Nice! :D

I've just uploaded the KDE (konsole) script to github.

Can you test it for us, please?

Thank you!
User avatar
rossdv8
Level 7
Level 7
Posts: 1737
Joined: Wed Apr 23, 2014 4:48 am
Location: Within 2,000 kilometres of Alice Springs, Australia
Contact:

Re: NORD VPN - Simple GUI

Post by rossdv8 »

Yep - off to have a look now.

Remember though that almost no Mint users other than me are likely to use konsole as a Terminal.
I'm an odd fish. I like things like transparent Apps and Video Wallpaper - which is why I use Mint Xfce :)

E D I T:

The new script is bringing up my old GUI instead of the new changes.
That means it is doing the default of displaying a new Terminal screen (and result) every time a button is pressed then returning to to the GUI as the Terminal is closed, rather than leaving the terminal open all the time, and just displaying each result.

Leaving the terminal open all the time was something I didn;t manage to make it do and I just didn;t bother. But after seeing the screenshots - I think it is far better the way you did it, so I'll have to see what is making it fail here.

This is exactly what it was doing when I played with gnome-terminal and xfce4-terminal.

I guess I'll have to double check paths and stuff.
Current main OS: MInt 21.3 with KDE Plasma 5.27 (using Compiz as WM) - Kernel: 6.5.0-15 on Lenovo m900 Tiny, i5-6400T (intel HD 530 graphics) 16GB RAM.
Sharks usually only attack you if you are wet
Locked

Return to “Chat about Linux Mint”