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

How to properly autoconnect on startup

Open sojusnik opened this issue 4 years ago • 4 comments

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

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

  • [x] I have searched open and closed issues for duplicates
  • [x] This isn't a feature request
  • [x] This is not a report about my app not working as expected

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?

sojusnik avatar Aug 08 '21 07:08 sojusnik

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.

unchartedpopsicle avatar Sep 02 '21 13:09 unchartedpopsicle

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

sojusnik avatar Sep 03 '21 09:09 sojusnik

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.

natanjunges avatar Oct 27 '21 22:10 natanjunges

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 &

git-en avatar Jul 25 '22 02:07 git-en