Skip to content

Instantly share code, notes, and snippets.

@ahallrq
Created August 27, 2019 01:32
Show Gist options
  • Select an option

  • Save ahallrq/74af57b1422b87fda8b8a5d3950f0d10 to your computer and use it in GitHub Desktop.

Select an option

Save ahallrq/74af57b1422b87fda8b8a5d3950f0d10 to your computer and use it in GitHub Desktop.
NordVPN server selection on Ganoo slash Loonecks that's not completely fucked (needs dmenu, ask your local Arch Linux virgin for a copy)
#!/bin/bash
# Run with "disconn_only" to only show the disconnection dialog
nordvpn_status="$(nordvpn status)"
nordvpn_connection=$(echo "$nordvpn_status" | grep "Status" | awk '{print $2}')
if [ "$nordvpn_connection" == "Connected" ];
then
nordvpn_server=$(echo "$nordvpn_status" | grep "Current server" | cut -f 3- -d ' ')
nordvpn_country=$(echo "$nordvpn_status" | grep "Country" | cut -f 2- -d ' ')
nordvpn_city=$(echo "$nordvpn_status" | grep "City" | cut -f 2- -d ' ')
if [ $(echo -e "Yes\nNo" | dmenu -p "Currently connected to $nordvpn_server ($nordvpn_country/$nordvpn_city). Disconnect?") == "Yes" ]; then
notify-send -i /var/lib/nordvpn/icon.svg "NordVPN" "Disconnecting from $nordvpn_server ($(echo $nordvpn_country | tr "_" " ")/$nordvpn_city).";
nordvpn d;
else
exit;
fi
fi
if [ "$1" == "disconn_only" ]; then exit; fi
export country=$(nordvpn countries | tail -c +7 | tr "_" " " | tr -s "\t" "\n" | tr -s "," "\n" | sort | dmenu -p "NordVPN Country")
if [ "$country" == "" ]; then exit; fi
notify-send -i /var/lib/nordvpn/icon.svg "NordVPN" "Attempting to connect to NordVPN via $country.";
nordvpn c $(echo $country | tr " " "_")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment