ProtonVPN / proton-vpn-gtk-app

Official ProtonVPN Linux app
https://protonvpn.com/download-linux
GNU General Public License v3.0
152 stars 20 forks source link

Linux: minimise on start option #20

Closed thunderbird-93 closed 2 months ago

thunderbird-93 commented 6 months ago

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

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


Hope this helps those struggling. I want to believe that Proton team will add an option to start apps into system tray at some point. Meanwhile this is my solution.

I am using both Proton VPN & Mail Bridge on Ubuntu with Gnome. In my case these are flatpaks but I don't think that matters. Here's what I ended up load both apps minimized to system tray. Just add this script to your startup apps.

proton-startup.sh

#!/bin/bash

# Proton VPN
gtk-launch com.protonvpn.www.desktop </dev/null &>/dev/null &
xdotool search --sync --name "Proton VPN" windowactivate
xdotool key --clearmodifiers --delay 500 alt+F4

# Proton Mail Bridge
gtk-launch ch.protonmail.protonmail-bridge.desktop </dev/null &>/dev/null &
xdotool search --sync --name "Proton Mail Bridge" windowactivate
xdotool key --clearmodifiers --delay 500 alt+F4
fthx commented 6 months ago

Using Ubuntu/GNOME too but official gtk app package. I told Proton customer service that there is an odd behaviour here:

Useful for those who want Proton VPN app silently running. But clearly a not intended behaviour. I'll write now an extension that can hide Proton VPN window at start-up (+ button show/hide in systray).

fthx commented 6 months ago

Ok, here is the extension: https://extensions.gnome.org/extension/6631/proton-vpn-button/

That's a very light extension. I checked carefully at logs to track bugs.

This has to be tested against a Flatpak setup.

fthx commented 6 months ago

@calexandru2018 @jllaneras @ProtonVPN

fthx commented 6 months ago

And FYI I just did the same for bridge (that can natively start hidden, though): https://extensions.gnome.org/extension/6634/proton-bridge-button/

@ProtonMail

thunderbird-93 commented 6 months ago

@fhtx, thanks for sharing those extensions. Do you mean Bridge --no-window argument? Didn't work for some reason. Maybe because of flatpak... Anyway, we have workarounds for now. One day devs might hopefully look into it. Seems like a very basic functionality to expect from something running at boot.

fthx commented 6 months ago

I reverted these two extensions to a simple open/close app. It's for my usage fully ok, once the trick (I told about above) done for VPN app, to make the window close without quitting VPN app. It's annoying to simply have these apps minimized since they take place in overview anyway.

Since it seems we don't have API for VPN app yet, I don't know how to do better.

I can repeat what I told to customer service: Ubuntu AppIndicators is a very heavy and buggy extension with thousands lines of code and I don't think it's a good idea to use it in GNOME. Just my opinion.

calexandru2018 commented 6 months ago

Hey @fthx, Really appreciate your contribution 🚀 I read your code and saw that you communicate directly to gnome shell, which definitely is a cleaner solution then going via the extensions route. I wonder though if this would this work with KDE backends (I suspect not but I haven't tested) ? I'm saying this mainly because even though we have limited support for other DEs other then GNOME, the ExtensionIndicator works quite well cross-DEs (mainly Gnome, KDE, Mint, Cinnamon), that's why we resorted to that one.

But eventually in the long run we do plan to add support so that the app start once the user has logged in (mainly because we need access to the keyring which only gets unlocked after the user has logged in).

I told Proton customer service that there is an odd behaviour here:

install gtk app and run VPN
closing the app does close VPN
activate Ubuntu appindocators extension
closing the app does hide the window app
deactivate Ubuntu appindicators extension
closing the app does hide the window app

Useful for those who want Proton VPN app silently running. But clearly a not intended behavior.

I see your point here, in the last step it should close the app, and it's indeed a bug that has to be fixed. But there is a specific reason why we disconnect at app quit (as do other clients on their respective platforms), and is mainly for reliability. If a server goes into maintenance, or there is a network drop/switch, you'd be left without internet connection because NM does not re-enable VPN connection automatically unless you add it as secondaries to your main connection, and to rely on secondaries is honestly not a very robust approach because your main connection could switch anytime and you'd be left unprotected. This also includes KS management which needs to work in tandem with the connection module. If you'd like to understand a bit more about this I'd suggest you take a look at the following packages (in the following order):

  1. https://github.com/ProtonVPN/python-proton-vpn-connection
  2. https://github.com/ProtonVPN/python-proton-vpn-network-manager
  3. https://github.com/ProtonVPN/python-proton-vpn-network-manager-openvpn
  4. https://github.com/ProtonVPN/python-proton-vpn-killswitch
  5. https://github.com/ProtonVPN/python-proton-vpn-killswitch-network-manager
  6. https://github.com/ProtonVPN/python-proton-vpn-api-core
fthx commented 6 months ago

But eventually in the long run we do plan to add support so that the app start once the user has logged in (mainly because we need access to the keyring which only gets unlocked after the user has logged in).

Hmm I do not understand your point here: I did add ProtonVPN to startup apps in GNOME and it works perfectly. What we need imo here is clearly a --no-window command line option, as Bridge does when I activate the autostart pref in app settings.

But there is a specific reason why we disconnect at app quit (as do other clients on their respective platforms), and is mainly for reliability.

Ok but when I close the app window (or apply request_quit() to GNOME Shell app), the app is still running. So maybe offer a pref to the user (really quit the app on window closed) vs (keep the app running on window closed), whatever could the user have installed once Ubuntu AppIndicators?

If we get some command line options, I can add them to icon's menu (atm there is no menu).

calexandru2018 commented 2 months ago

We have this in the plans but no ETA on this.

Edit: see my answer here