linux-app icon indicating copy to clipboard operation
linux-app copied to clipboard

Add at least basic settings

Open toxpal opened this issue 3 years ago • 22 comments

Just installed the app on Manjaro KDE and... well, it's completely useless because no single setting exists in the app. While Android app is great, Linux app lacks these settings:

  1. Start on boot. Now, even if I set kill switch as permanent, it has no effect because it only works when app is launched. Forgot to launch app manually every single time after (re)booting OS? Too bad, you are not protected.
  2. Create default profile. My workplace only allows connections from whitelisted IPs, so it's extremely important my IP is the same every single time after VPN connection is established (in other words, I don't want to connect to a random server every time).
  3. Allow minimizing app into the tray. Now, it either runs as a "normal" app in a separate window, either it doesn't work at all because closing app.. well, literally closes it.

While I like your service (migrated from Nord VPN) and your policy/transparency, I was actually shocked to see that you released Linux app which only provides a false sense of security and actually does almost nothing. But your Android app is OK, so I surely know you can do it.

toxpal avatar Jun 01 '21 18:06 toxpal

Hey @toxpal

So to answer to some of your questions:

  1. It is planned, but until then you could use something that linux already offers out-of-the box, a .service configuration within --user space. Also not sure by what you mean about the killswitch, could you please provide more details ?
  2. TBD
  3. That actually works atm but only on DE that actually support it natively. If you look at the SPEC file you can see that the dependency is there, but given that linux does not have a "native" tray implementation in place (due to DE fragmentation) it often is hard to enforce having a systray, it is although achievable.

calexandru2018 avatar Jun 07 '21 14:06 calexandru2018

Thank you for your response, I trust in Proton again... :)

toxpal avatar Jun 07 '21 16:06 toxpal

Hey @toxpal

So to answer to some of your questions:

  1. It is planned, but until then you could use something that linux already offers out-of-the box, a .service configuration within --user space. Also not sure by what you mean about the killswitch, could you please provide more details ?

How exactly would one go about doing this? I currently have Protonvpn configured to start on boot using Manjaro's Autostart feature, however the VPN will not automatically turn on, and must be activated manually. Is there a way to auto-activate the connection in addition to simply auto-opening the application? If not, is this feature in the works?

asorel1942 avatar Jul 18 '21 14:07 asorel1942

  1. Start on boot. Now, even if I set kill switch as permanent, it has no effect because it only works when app is launched. Forgot to launch app manually every single time after (re)booting OS? Too bad, you are not protected.

How exactly would one go about doing this? I

In Linux Mint I can go to "Startup Applications" and add it there: image

gavinr avatar Aug 26 '21 22:08 gavinr

Update: in Linux Mint, after adding it there ^, simply click the "modify" icon and change it to this: Selection_009

... this seems to work for me! It does not run the GUI, but you are connected to the VPN (check by going to https://ip.me) and if you open the GUI it does say connected.

gavinr avatar Sep 01 '21 05:09 gavinr

Hey @toxpal So to answer to some of your questions:

  1. It is planned, but until then you could use something that linux already offers out-of-the box, a .service configuration within --user space. Also not sure by what you mean about the killswitch, could you please provide more details ?

How exactly would one go about doing this? I currently have Protonvpn configured to start on boot using Manjaro's Autostart feature, however the VPN will not automatically turn on, and must be activated manually. Is there a way to auto-activate the connection in addition to simply auto-opening the application? If not, is this feature in the works?

I created a systemd service in user space, as @calexandru2018 mentioned. It works quite well, it waits for network-online.target (it needs NetworkManager to be fully initialized), connects automatically, opens the GUI and disconnects automatically on logout. It also restarts itself in case it fails to start.

[Unit]
Description=ProtonVPN autostart

[Service]
Type=oneshot
RemainAfterExit=yes
# Waits until it is online. It is required because system targets cannot be used in user services.
ExecStartPre=sh -c "until systemctl is-active network-online.target; do sleep 1; done"
ExecStart=protonvpn-cli c -f
ExecStartPost=-sh -c "protonvpn &"
TimeoutStartSec=30
ExecStop=protonvpn-cli d
Restart=on-failure

[Install]
WantedBy=default.target

To use it, just save it in ~/.config/systemd/user/protonvpn-autostart.service, reload the systemd daemon with systemctl --user daemon-reload and enable it with systemctl --user enable protonvpn-autostart.

I could not get it working reliably with Kill Switch enabled at first, but the solution from https://github.com/ProtonVPN/linux-cli/issues/44#issuecomment-911701915 seems to have worked. Just insert these two lines after RemainAfterExit=yes:

ExecStartPre=-protonvpn-cli ks --off
ExecStartPre=-protonvpn-cli ks --on

Then reload the systemd daemon with systemctl --user daemon-reload.

natanjunges avatar Oct 27 '21 21:10 natanjunges

I like your solution but I can't get it to work on my Kubuntu 20.04 system. No graphical-session.target is active, what should I do if it isn't active?

I think it's more reliable to use autostart as on https://github.com/ProtonVPN/linux-cli/issues/44, but I don't know.

pehlm avatar Oct 29 '21 18:10 pehlm

I updated the service to address this issue. It is now using the more generic default.target, as some distributions don't implement the graphical-session.target yet (and the graphical session is only required to open the GUI, which is optional).

natanjunges avatar Oct 31 '21 19:10 natanjunges

I did the pull request https://github.com/ProtonVPN/linux-cli/pull/55 that implements this service. You are all welcome to test it and give feedback.

natanjunges avatar Nov 08 '21 14:11 natanjunges

@natanjunges Thank you for this very useful script.

I still have a small a problem :

On Ubuntu 21.10, protonMail bridge starts with Startup Applications. With protonvpn starting with your script, protonmail Bridge indicates an error : no network, with a red dot on its icon. I have to restart it manually to remove this error.

Is there a way to start protonMail bridge from systemd after protonvpn?

thank you

francoisromain avatar Jan 08 '22 13:01 francoisromain

Hi @francoisromain, I don't use ProtonMail Bridge, but I think it can indeed be started as a systemd user service. It would need the following line in the Unit section to make sure it will wait for the ProtonVPN service:

After=protonvpn-autostart.service

natanjunges avatar Jan 09 '22 16:01 natanjunges

I created a systemd service in user space, as @calexandru2018 mentioned. It works quite well, it waits for network-online.target (it needs NetworkManager to be fully initialized), connects automatically, opens the GUI and disconnects automatically on logout. It also restarts itself in case it fails to start.

[Unit]
Description=ProtonVPN autostart

[Service]
Type=oneshot
RemainAfterExit=yes
# Waits until it is online. It is required because system targets cannot be used in user services.
ExecStartPre=sh -c "until systemctl is-active network-online.target; do sleep 1; done"
ExecStart=protonvpn-cli c -f
ExecStartPost=-sh -c "protonvpn &"
TimeoutStartSec=30
ExecStop=protonvpn-cli d
Restart=on-failure

[Install]
WantedBy=default.target

I have Fedora 35 with KDE spin installed. With that script, every time I log into the desktop, KDE Wallet always asks for a password. This probably occurs because of this KDE bug. My temporary solution is replacing ExecStartPre=sh -c "until systemctl is-active network-online.target; do sleep 1; done" with ExecStartPre=sh -c "until ping -c 1 9.9.9.9; do sleep 1; done" which will waits until it is connected to the internet. The complete script will look like this:

[Unit]
Description=ProtonVPN autostart

[Service]
Type=oneshot
RemainAfterExit=yes
# Waits until internet is connected.
ExecStartPre=sh -c "until ping -c 1 9.9.9.9; do sleep 1; done"
ExecStart=protonvpn-cli c -f
TimeoutStartSec=30
ExecStop=protonvpn-cli d
Restart=on-failure

[Install]
WantedBy=default.target

I'm not expert at coding. Just wanted to share this little hack, in case someone else encounters the same problem. Please, feel free to correct and improve the code.

quadratz avatar Mar 09 '22 05:03 quadratz

Hey @toxpal So to answer to some of your questions:

  1. It is planned, but until then you could use something that linux already offers out-of-the box, a .service configuration within --user space. Also not sure by what you mean about the killswitch, could you please provide more details ?

How exactly would one go about doing this? I currently have Protonvpn configured to start on boot using Manjaro's Autostart feature, however the VPN will not automatically turn on, and must be activated manually. Is there a way to auto-activate the connection in addition to simply auto-opening the application? If not, is this feature in the works?

I created a systemd service in user space, as @calexandru2018 mentioned. It works quite well, it waits for network-online.target (it needs NetworkManager to be fully initialized), connects automatically, opens the GUI and disconnects automatically on logout. It also restarts itself in case it fails to start.

[Unit]
Description=ProtonVPN autostart

[Service]
Type=oneshot
RemainAfterExit=yes
# Waits until it is online. It is required because system targets cannot be used in user services.
ExecStartPre=sh -c "until systemctl is-active network-online.target; do sleep 1; done"
ExecStart=protonvpn-cli c -f
ExecStartPost=-sh -c "protonvpn &"
TimeoutStartSec=30
ExecStop=protonvpn-cli d
Restart=on-failure

[Install]
WantedBy=default.target

To use it, just save it in ~/.config/systemd/user/protonvpn-autostart.service, reload the systemd daemon with systemctl --user daemon-reload and enable it with systemctl --user enable protonvpn-autostart.

I could not get it working reliably with Kill Switch enabled at first, but the solution from ProtonVPN/linux-cli#44 (comment) seems to have worked. Just insert these two lines after RemainAfterExit=yes:

ExecStartPre=-protonvpn-cli ks --off
ExecStartPre=-protonvpn-cli ks --on

Then reload the systemd daemon with systemctl --user daemon-reload.

Hi, thanks for the awesome script, it works, but for the killswitch, adding those lines don't seem to enable it, when i check the status with protonvpn-cli.

ShabirK21 avatar Jul 28 '22 06:07 ShabirK21

So on Zorin OS 16.1 I tried this:

[Unit]
Description=ProtonVPN autostart

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=-protonvpn-cli ks --off
ExecStartPre=-protonvpn-cli ks --on
# Waits until it is online. It is required because system targets cannot be used in user services.
ExecStartPre=sh -c "until ping -c1 google.com; do sleep 1; done"
ExecStart=protonvpn-cli c -f
ExecStartPost=-sh -c "protonvpn &"
TimeoutStartSec=30
ExecStop=protonvpn-cli d
Restart=on-failure

[Install]
WantedBy=default.target

But the service fails to start with protonvpn_nm_lib.exceptions.KeyringError: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

Nottt avatar Aug 05 '22 17:08 Nottt

  • It is planned, but until then you could use something that linux already offers out-of-the box, a .service configuration within --user space.
  • TBD

So more than 14 months have passed, I installed the app again, and.. nothing?

toxpal avatar Aug 28 '22 07:08 toxpal

Update: in Linux Mint, after adding it there ^, simply click the "modify" icon and change it to this: Selection_009

... this seems to work for me! It does not run the GUI, but you are connected to the VPN (check by going to https://ip.me) and if you open the GUI it does say connected.

Nice! And if the DE used does not allow you modify the startup command after activating it you can go to the ~/.config/autostart/protonvpn.desktop file and modify in a text editor. The systemd service above also looks good but since the pull request has not been merged I think this is the simplest solution since it's just a file in the /home folder.

matheuswillder avatar Sep 09 '22 07:09 matheuswillder

Hey @toxpal So to answer to some of your questions:

  1. It is planned, but until then you could use something that linux already offers out-of-the box, a .service configuration within --user space. Also not sure by what you mean about the killswitch, could you please provide more details ?

How exactly would one go about doing this? I currently have Protonvpn configured to start on boot using Manjaro's Autostart feature, however the VPN will not automatically turn on, and must be activated manually. Is there a way to auto-activate the connection in addition to simply auto-opening the application? If not, is this feature in the works?

I created a systemd service in user space, as @calexandru2018 mentioned. It works quite well, it waits for network-online.target (it needs NetworkManager to be fully initialized), connects automatically, opens the GUI and disconnects automatically on logout. It also restarts itself in case it fails to start.

[Unit]
Description=ProtonVPN autostart

[Service]
Type=oneshot
RemainAfterExit=yes
# Waits until it is online. It is required because system targets cannot be used in user services.
ExecStartPre=sh -c "until systemctl is-active network-online.target; do sleep 1; done"
ExecStart=protonvpn-cli c -f
ExecStartPost=-sh -c "protonvpn &"
TimeoutStartSec=30
ExecStop=protonvpn-cli d
Restart=on-failure

[Install]
WantedBy=default.target

To use it, just save it in ~/.config/systemd/user/protonvpn-autostart.service, reload the systemd daemon with systemctl --user daemon-reload and enable it with systemctl --user enable protonvpn-autostart.

I could not get it working reliably with Kill Switch enabled at first, but the solution from https://github.com/ProtonVPN/linux-cli/issues/44#issuecomment-911701915 seems to have worked. Just insert these two lines after RemainAfterExit=yes:

ExecStartPre=-protonvpn-cli ks --off
ExecStartPre=-protonvpn-cli ks --on

Then reload the systemd daemon with systemctl --user daemon-reload.

Hey, I tried this but it didn't work on Debian 11 (GNOME). Is it still working or am I missing something?

I followed the instructions and played with settings a little bit to see of it changes anything, but it doesn't connect at all..

Engineer22 avatar Sep 15 '22 14:09 Engineer22

In my case this service unit failed because it starts before the user login, hence the vpn password is locked. My solution was to change the last line from WantedBy=default.target to WantedBy=xdg-desktop-autostart.target. Then disable and enable the service.

Juankz avatar Oct 04 '22 17:10 Juankz