Skip to content

Commit

Permalink
[vpnLookOut@claudiux]: v2.2.0 - Now compatible with Archlinux (linuxm…
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiux authored and jaszhix committed May 24, 2018
1 parent ddd22fb commit 49d1305
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 37 deletions.
4 changes: 4 additions & 0 deletions vpnLookOut@claudiux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

### 2.2.0
* Now compatible with Arch Linux.
* Improved compatibility with Fedora 27.

### 2.1.0
* Now compatible with Fedora 27.

Expand Down
33 changes: 15 additions & 18 deletions vpnLookOut@claudiux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ But also, it can try to reconnect when VPN shuts down incidentally, and it can c

## Status

Fully supported by Author, under continuing development and in continuous use on several machines.
Fully supported by Author, under continuing development and in continuous use on several machines, running with **LinuxMint**, **Fedora** or **Archlinux**.

## Features

Expand All @@ -20,7 +20,7 @@ The VPN Look-Out Applet normally shows an icon that changes color depending on t
* Red: the VPN is disconnected.
* Grey: waiting for VPN status (only when the applet starts, for a few seconds, or if it's misconfigured).

When hovering over or click on the icon, the status of the VPN is displayed with, in parentheses, the name of the connection and the network interface used. By example:
When hovering over or click on the icon, the status of the VPN is displayed with, in parentheses, the name of the connection and the network interface used. By example:

VPN: Connected (Amsterdam / tun0)

Expand All @@ -42,7 +42,7 @@ The left click menu also contains:
* A button to connect to (or disconnect from) the last VPN used. This button appears only if the option "Try to reconnect to VPN when it shuts down incidentally" is unchecked.
* A list of all VPN connections available. Click on one of them to change of VPN connection ; it disconnects from actual (if any) and connects to new.

## Translations
## Translations
The vpnLookOut applet is designed to allow translations of messages (initially in English). A vpnLookOut.pot template file is available, you can use it with software such as poedit to translate these messages.

Languages already available (v2.0.0 and following): English, French, Spanish, Italian.
Expand All @@ -57,11 +57,15 @@ While comments and suggestions are always welcome, any contributions considered

## Requirements:

Cinnamon Version 1.8 or higher as it makes comprehensive use of the new Cinnamon Settings Interface for Applets and Desklets. The latest versions have been tested on Cinnamon 3.4.6 and Mint 18.2.
Cinnamon Version 1.8 or higher as it makes comprehensive use of the new Cinnamon Settings Interface for Applets and Desklets. The latest versions have been tested on Cinnamon 3.4.6 and Mint 18.2.

For full facilities including notifications and audible alerts the ```zenity sox``` and ```libsox-fmt-mp3``` libraries must be installed. They can be installed wih the Synaptic Package Manager or using the following terminal command:

apt install zenity sox libsox-fmt-mp3
* LinuxMint:
apt update && apt install zenity sox libsox-fmt-mp3
* Fedora:
sudo dnf update && sudo dnf install zenity sox
* Archlinux:
sudo pacman -Syu zenity sox

**Note that this applet helps you to install these dependencies, if any.**

Expand All @@ -78,16 +82,9 @@ You can install Transmission:
apt install transmission transmission-gtk

## Manual Installation:

* Install the additional programs required.
* Download the VPN Look-Out Applet from the Spices Web Site
* Download the VPN Look-Out Applet from the Spices Web Site.
* Unzip and extract folder ```vpnLookOut@claudiux``` to ```~/.local/share/cinnamon/applets/```
* Enable the applet in System Settings -> Applets
* You can also access the Settings Screen from System Settings -> Applets or from the Applets Context menu

## TO DO in next versions (following v2.0.0):

If required by users, I project to:
* Add an option to start Transmission when this applet starts, as soon as the VPN is connected.
* Add an option to log VPN connections/disconnections for statistics.
* Add a tool to append VPN connections from a .ovpn config file containing settings and certificates, for personal use only (not for system-wide use, which requires root privileges).
* Enable the applet in System Settings -> Applets.
* You can also access the Settings Screen from System Settings -> Applets, or from the Applets Context menu.
4 changes: 4 additions & 0 deletions vpnLookOut@claudiux/files/vpnLookOut@claudiux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

### 2.2.0
* Now compatible with Arch Linux.
* Improved compatibility with Fedora 27.

### 2.1.0
* Now compatible with Fedora 27.

Expand Down
26 changes: 15 additions & 11 deletions vpnLookOut@claudiux/files/vpnLookOut@claudiux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ But also, it can try to reconnect when VPN shuts down incidentally, and it can c

## Status

Fully supported by Author, under continuing development and in continuous use on several machines.
Fully supported by Author, under continuing development and in continuous use on several machines, running with **LinuxMint**, **Fedora** or **Archlinux**.

## Features

Expand All @@ -20,7 +20,7 @@ The VPN Look-Out Applet normally shows an icon that changes color depending on t
* Red: the VPN is disconnected.
* Grey: waiting for VPN status (only when the applet starts, for a few seconds, or if it's misconfigured).

When hovering over or click on the icon, the status of the VPN is displayed with, in parentheses, the name of the connection and the network interface used. By example:
When hovering over or click on the icon, the status of the VPN is displayed with, in parentheses, the name of the connection and the network interface used. By example:

VPN: Connected (Amsterdam / tun0)

Expand All @@ -42,7 +42,7 @@ The left click menu also contains:
* A button to connect to (or disconnect from) the last VPN used. This button appears only if the option "Try to reconnect to VPN when it shuts down incidentally" is unchecked.
* A list of all VPN connections available. Click on one of them to change of VPN connection ; it disconnects from actual (if any) and connects to new.

## Translations
## Translations
The vpnLookOut applet is designed to allow translations of messages (initially in English). A vpnLookOut.pot template file is available, you can use it with software such as poedit to translate these messages.

Languages already available (v2.0.0 and following): English, French, Spanish, Italian.
Expand All @@ -57,11 +57,15 @@ While comments and suggestions are always welcome, any contributions considered

## Requirements:

Cinnamon Version 1.8 or higher as it makes comprehensive use of the new Cinnamon Settings Interface for Applets and Desklets. The latest versions have been tested on Cinnamon 3.4.6 and Mint 18.2.
Cinnamon Version 1.8 or higher as it makes comprehensive use of the new Cinnamon Settings Interface for Applets and Desklets. The latest versions have been tested on Cinnamon 3.4.6 and Mint 18.2.

For full facilities including notifications and audible alerts the ```zenity sox``` and ```libsox-fmt-mp3``` libraries must be installed. They can be installed wih the Synaptic Package Manager or using the following terminal command:

apt install zenity sox libsox-fmt-mp3
* LinuxMint:
apt update && apt install zenity sox libsox-fmt-mp3
* Fedora:
sudo dnf update && sudo dnf install zenity sox
* Archlinux:
sudo pacman -Syu zenity sox

**Note that this applet helps you to install these dependencies, if any.**

Expand All @@ -78,9 +82,9 @@ You can install Transmission:
apt install transmission transmission-gtk

## Manual Installation:

* Install the additional programs required.
* Download the VPN Look-Out Applet from the Spices Web Site
* Download the VPN Look-Out Applet from the Spices Web Site.
* Unzip and extract folder ```vpnLookOut@claudiux``` to ```~/.local/share/cinnamon/applets/```
* Enable the applet in System Settings -> Applets
* You can also access the Settings Screen from System Settings -> Applets or from the Applets Context menu
* Enable the applet in System Settings -> Applets.
* You can also access the Settings Screen from System Settings -> Applets, or from the Applets Context menu.
50 changes: 44 additions & 6 deletions vpnLookOut@claudiux/files/vpnLookOut@claudiux/applet.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ MyApplet.prototype = {
this.textEd = "xed";
}

// Check that all Dependencies Met by presence of sox and zenity
// get a terminal used on this system
this.terminal = this.get_terminal();

// Check that all dependencies are installed (by presence of sox and zenity)

if (this.are_dependencies_installed()) {
this.dependenciesMet = true;
Expand All @@ -190,12 +193,17 @@ MyApplet.prototype = {
icon_type: St.IconType.FULLCOLOR,
icon_size: 36 });
let _isFedora = GLib.find_program_in_path("dnf");
let _apt = _isFedora ? "dnf" : "apt";
let _libsox = _isFedora ? "" : "libsox-fmt-mp3";
let criticalMessage = _("You appear to be missing some of the programs required for this applet to have all its features including notifications and audible alerts.")+"\n\n"+_("Please execute, in the just opened terminal, the commands:")+"\nsudo "+ _apt +" update\nsudo "+ _apt +" install zenity sox "+ _libsox +"\n\n";
let _ArchlinuxWitnessFile = Gio.file_new_for_path("/etc/arch-release");
let _isArchlinux = _ArchlinuxWitnessFile.query_exists(null);
let _apt_update = _isFedora ? "sudo dnf update" : _isArchlinux ? "" : "sudo apt update";
let _and = _isFedora ? " \\\\&\\\\& " : _isArchlinux ? "" : " \\\\&\\\\& ";
var _apt_install = _isFedora ? "sudo dnf install zenity sox" : _isArchlinux ? "sudo pacman -Syu zenity sox" : "sudo apt install zenity sox libsox-fmt-mp3";
let _libsox = (_isFedora || _isArchlinux) ? "" : "libsox-fmt-mp3";
let criticalMessage = _("You appear to be missing some of the programs required for this applet to have all its features including notifications and audible alerts.")+"\n\n"+_("Please execute, in the just opened terminal, the commands:")+"\n "+ _apt_update +" \n "+ _apt_install +"\n\n";
this.notification = criticalNotify(_("Some dependencies are not installed!"), criticalMessage, icon);
// Translators: The next message should not be translated.
GLib.spawn_command_line_async("gnome-terminal -e 'sh -c \"echo vpnLookOut Applet message: Some packages needed!\\\\\\\\nTo complete the installation, please enter and execute the command: \\\\\\\\nsudo "+ _apt +" update \\\\&\\\\& sudo "+ _apt +" install zenity sox "+ _libsox+ "; sleep 1; exec bash\"'");
if (this.terminal != "")
GLib.spawn_command_line_async(this.terminal + " -e 'sh -c \"echo vpnLookOut Applet message: Some packages needed!; echo To complete the installation, please enter and execute the command: ; echo "+ _apt_update + _and + _apt_install + "; sleep 1; exec bash\"'");
this.dependenciesMet = false;
}

Expand All @@ -220,7 +228,7 @@ MyApplet.prototype = {
if (this.dependenciesMet) {
this.set_applet_tooltip(_("Waiting"));
} else {
this.set_applet_tooltip(_apt+" install zenity sox libsox-fmt-mp3");
this.set_applet_tooltip(_apt_install);
}

// If required, connect on last VPN
Expand Down Expand Up @@ -256,6 +264,12 @@ MyApplet.prototype = {
soxmp3WitnessFile = Gio.file_new_for_path(soxmp3WitnessPath);
soxmp3Installed = soxmp3WitnessFile.query_exists(null);
}
if (!soxmp3Installed) {
// for ArchLinux
soxmp3WitnessPath = "/usr/lib/sox/libsox_fmt_mp3.so";
soxmp3WitnessFile = Gio.file_new_for_path(soxmp3WitnessPath);
soxmp3Installed = soxmp3WitnessFile.query_exists(null);
}
return (soxmp3Installed && GLib.find_program_in_path("sox") && GLib.find_program_in_path("zenity"))
}, // End of are_dependencies_installed

Expand Down Expand Up @@ -348,6 +362,30 @@ MyApplet.prototype = {
}
}, // End of vpn_interface_detect

_witness: function( path) {
let witnessFile = Gio.file_new_for_path(path);
return witnessFile.query_exists(null);
}, //End of _witness

get_distrib: function() {
if (this._witness("/etc/arch-release")) return "Arch";
if (this._witness("/etc/fedora-release")) return "Fedora";
return "Mint"
}, // End of get_distrib

get_terminal: function() {
var term_found = "";
var _terminals = ["gnome-terminal", "tilix", "konsole", "guake", "qterminal", "terminator", "uxterm", "xterm"];
var t;
for (t=0; t < _terminals.length ; t++) {
if (GLib.find_program_in_path(_terminals[t])) {
term_found = _terminals[t];
break
}
}
return term_found
}, // End of get_terminal

get_vpn_names: function() {
let [res, out, err, status] = GLib.spawn_command_line_sync('sh -c ' + this.appletPath + "/scripts/vpn_names.sh");
let list_vpn_names=[];
Expand Down
3 changes: 1 addition & 2 deletions vpnLookOut@claudiux/files/vpnLookOut@claudiux/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"uuid": "vpnLookOut@claudiux",
"max-instances": "1",
"name": "VPN Look-Out Applet",
"version": "2.1.0",
"last-edited": 1526150600,
"version": "2.2.0",
"hide-configuration": false,
"description": "A Cinnamon applet that watches over the VPN link, displays its status, allows to connect at start-up to the last VPN used, allows to reconnect the VPN link if it incidentally drops, and can stop or restart Transmission according to the state of the VPN."
}

0 comments on commit 49d1305

Please sign in to comment.