How to properly autoconnect on startup
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?
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.
@masytan Thanks, you're awesome! Works flawlessly!
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.
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 &