ProtonVPN / linux-cli

Official ProtonVPN Linux app (CLI)
https://protonvpn.com/download-linux
GNU General Public License v3.0
335 stars 43 forks source link

How to properly autoconnect on startup #44

Open sojusnik opened 3 years ago

sojusnik commented 3 years ago

We are happy to answer your questions about the code or discuss technical ideas.

Please complete the following checklist (by adding [x]):


To autoconnect ProtonVPN at startup on Ubuntu 21.04, I've created a file in ~/.config/autostart/ (named it protonvpn-cli.desktop) with this content:

[Desktop Entry]
Type=Application
Exec=/usr/bin/protonvpn-cli c -f
Icon=protonvpn-logo
Name=ProtonVPN CLI
Terminal=false
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true

But there is a delay of 1-2 minutes (as if ProtonVPN is waiting for a timeout) before ProtonVPN starts establishing a connection after startup. After this delay a VPN icon appears in Gnome's system tray and within seconds the VPN connection is finally established. Before this, I have no internet connection, probably because the kill switch is enabled in the GUI of ProtonVPN.

So what's the right way to have autoconnection on startup without this delay?

unchartedpopsicle commented 2 years ago

I pointed that autostart file to a script that resets the kill-switch before connecting:

#!/bin/bash

protonvpn-cli ks --off
protonvpn-cli ks --on
protonvpn-cli c -f

That fixed this problem for me on Pop!_OS.

sojusnik commented 2 years ago

@masytan Thanks, you're awesome! Works flawlessly!

natanjunges commented 2 years ago

If you want a systemd service, that also waits for NetworkManager, connects automatically, opens the GUI and disconnects automatically on logout, check out my comment on https://github.com/ProtonVPN/linux-app/issues/4#issuecomment-953313052.

git-en commented 2 years ago

Start the nice little Proton GUI connection icon in your tray add this to "startup applications"

#!/bin/bash /usr/bin/protonvpn-cli ks --off && /usr/bin/protonvpn-cli c -f && protonvpn &