Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI opens up automatically after login on Wayland #535

Closed
Danny3 opened this issue Oct 25, 2021 · 17 comments
Closed

GUI opens up automatically after login on Wayland #535

Danny3 opened this issue Oct 25, 2021 · 17 comments

Comments

@Danny3
Copy link

Danny3 commented Oct 25, 2021

Describe the bug
Firewall's GUI opens up by itself immediately after login.
I noticed that this behavior happens only on the Wayland session.

Include the following information:

  • OpenSnitch version: 1.4.0 (even though I remember installing the latest 1.41, does it show the daemon's version ?)
  • OS: Kubuntu
  • Version: 21.10
  • Window Manager: KDE Plasma 5.23 (upgraded to it from the backports PPA)
  • Kernel version: Linux DL1 5.14.14-xanmod2 #0~git20211021.d659a56 SMP Thu Oct 21 05:44:46 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

To Reproduce
I enabled the Wayland session on KDE Plasma

Steps to reproduce the behavior:

  1. Go to 'System Settings'
  2. Then 'Startup and Shutdown'
  3. Then click on the 'Behavior...' button at the bottom of the page
  4. Tick the checkbox after 'Automatically log in:', if it's not already ticked
  5. Leave user in the drop-down as your user
  6. And then change the drop-down selection after 'with session" to 'Plasma (Wayland)'
  7. Click Apply button on the bottom of the page and rrestart computer

Post error logs:
I don't think they are needed for this problem, but I'll be more than happy to post them if required.

Expected behavior (optional)
Start the firewall the same way as the X11 session with the UI hidden by default and with the systray icon visible to show it when needed.

Screenshots

Additional context
I saw that in the System Settings -> Autostart there is one entry called "OpenSnitch" with its icon, but there's nothing else that could explain this behavior and there's no toggle button to temporary deactivate it for testing, only to delete it, which I tried to avoid.

This problem happened also with KDE Plasma 5.22 and 5.21, probably even with 5.20 or before, I don't even remember when I started using the Wayland session.

If somehow you cannot reproduce it, please try to also activate the systemd startup of KDE Plasma like I did with this command:
kwriteconfig5 --file startkderc --group General --key systemdBoot true

@gustavo-iniguez-goya
Copy link
Collaborator

Thank you @Danny3 for the detailed information.

If the GUI shows up just after login in it means that there's no system tray or the system tray widget is not active.
I'll try to reproduce it.

@Danny3
Copy link
Author

Danny3 commented Oct 26, 2021

Thank you @Danny3 for the detailed information.

If the GUI shows up just after login in it means that there's no system tray or the system tray widget is not active. I'll try to reproduce it.

No problem, thank you for looking into it !
I hope you have hardware that allows you to enable the Wayalnd session and be able to reproduce it.
As far as I know, Wayland should work without problems on Intel and AMD, but on Nvidia only after driver 495 and KDE Plasma 5.23.2 which I don't know when it will be released.
I don't think it's possible to enable it in a VM

Seeing your reply I did a few more tests just by logging out and logging back in keeping the Wayland session in the top drop-down menu.

You were right, when the window appears there's no system tray widget, because there's no system tray, not even the panel is loaded at that time.

The firewall's window is the first thing that appears after log in, then the panel and the Wifi connection enabled notification.

And I checked again the X11 session, also there the panel takes a second to appear after log in, just like on Wayland, but the firewall's window doesn't appear, just the system tray icon as expected.

BTW, I have disabled from the beginning KDE Plasma's 'Restore previous saved session' by choosing 'Start with an empty session' to not restore anything from the last session, so this should have no influence.

@gustavo-iniguez-goya
Copy link
Collaborator

I hope you have hardware that allows you to enable the Wayalnd session and be able to reproduce it.

It seems to be working fine :)

You were right, when the window appears there's no system tray widget, because there's no system tray, not even the panel is loaded at that time.

I haven't reproduced this problem yet, but I've run into another problem that might be related: I think the pop-ups dialogs are being fired before the desktop is fully loaded (causing undesired behaviour). That could explain why the GUI opens up.

I think this problem is more due to automatic login rather than Wayland. We'll see, I'll keep investigating this problem.

@gustavo-iniguez-goya
Copy link
Collaborator

@Danny3 add the following line to your .config/autostart/opensnitch_ui.desktop file, and let me know if it solves the issue:

X-KDE-Autostart-after=panel

@Danny3
Copy link
Author

Danny3 commented Oct 27, 2021

I haven't reproduced this problem yet, but I've run into another problem that might be related: I think the pop-ups dialogs are being fired before the desktop is fully loaded (causing undesired behaviour). That could explain why the GUI opens up.

I think this problem is more due to automatic login rather than Wayland. We'll see, I'll keep investigating this problem.

I don't know what to say, I have currently no new pop-up window as I have finished creating rules from all the previous pop-ups.

As for automatic login, I don't know, the issue happens also after I lot out and log in back again.

Logging back in requires my password so maybe this is a bit different.

@Danny3 add the following line to your .config/autostart/opensnitch_ui.desktop file, and let me know if it solves the issue:

X-KDE-Autostart-after=panel

Unfortunately it didn't solve the issue !

I tried also disabling the systemd boot of KDE Plasma that I activated previously, but it didn't help so I enabled it back.

Since you could not reproduce it, I am wondering what could be different, if I missed reporting something about my system and its configuration.

Maybe the fact that I'm using BTRFS instead of the normal EXT4.

The kernel is changend to Xanmod, but this issue was happening also with the default one.

@gustavo-iniguez-goya
Copy link
Collaborator

Unfortunately it didn't solve the issue !

Yes, you're right, I just reproduced it. Ok, no problem, I'll keep investigating it.

@gustavo-iniguez-goya
Copy link
Collaborator

Alright, I think we could workaround this problem for now.

Please, remove these lines from /usr/lib/python3/dist-packages/opensnitch/service.py after line 150:

if not self._tray.isSystemTrayAvailable():
    self._stats_dialog.show()

and add these ones:

          self._show_gui_if_tray_not_available()

      def _show_gui_if_tray_not_available(self):                                  
          tray = self._tray                                                       
          gui = self._stats_dialog
          def __show_gui():                     
              if not tray.isSystemTrayAvailable():                  
                  gui.show()                                                      

          QtCore.QTimer.singleShot(10000, __show_gui)                                                    

and let me know if the GUI shows up or if only the systray icon appears. If it shows up, change 10000 by 150000, but 10000 should be enough.

service.py attached, just it case you just want to replace it.
service.py.txt

@Danny3
Copy link
Author

Danny3 commented Oct 28, 2021

and let me know if the GUI shows up or if only the systray icon appears. If it shows up, change 10000 by 150000, but 10000 should be enough.

The workaround works, thank you very much !
The GUI doesn't shows up automatically anymore, and the systray icon is there.
Clicking on the icon to make it appear or disappear works also as expected.
Hopefully in the future we can find a proper way to query when the systray / panel has loaded, maybe we need to ask KDE developers.

Thanks for providing also the full file, I failed with the initial remove / add new lines and replacing the whole file was an easy fix.

I'm really happy now !

@gustavo-iniguez-goya
Copy link
Collaborator

great @Danny3 ! I need to test it on Gnome, maybe with this workaround we can get rid of the 3s delay for that DE.

I'll commit the fix soon.

@gustavo-iniguez-goya
Copy link
Collaborator

Ok, this is the proper fix: add the following line to /usr/share/kservices5/kcm_opensnitch.desktop:

X-KDE-Autostart-after=panel

Could you restore the original service.py, modify this file and see if the GUI shows up or not?

@Danny3
Copy link
Author

Danny3 commented Oct 30, 2021

I added that like after I uninstalled and installed OpenSnitch, since I didn't have the original service.py file anymore
Unfortunately the GUI shows up again !
For some reason the "X-KDE-Autostart-after=panel" doesn't seem to have any effect on my system.
I think I will have to try to install the firewall on a live session of Kubuntu 21.10 from a pendrive.
Maybe there's something conflicting because of my changes since I installed it.

@gustavo-iniguez-goya
Copy link
Collaborator

ok @Danny3 , thank you very much.

gustavo-iniguez-goya added a commit that referenced this issue Nov 4, 2021
Fixed GUI loading behaviour when DE's autologin is on.

Background:
 Sometimes the system tray is not available, so our app's icon
 does not show up. In this case we show the GUI to allow the user
 manage the rules and view connections.

If the user activated the autologin option, on KDE (and probably others)
our service was launched before the panel was ready, so the system tray was
not available yet and we were showing the Events window.

Changes:
- Delay 10s the check to see if the system tray is available, to give it
  time to load.
- Add X-KDE-Autostart-after=panel to kcm_opensnitch.desktop, to launch
  the GUI only after the panel is loaded.
- Misc: removed OpenSnitch entry from System Settings on KDE, and update
  the categories where the app is shown in the menus.

Closes #535
@mariomadproductions
Copy link

I'm having this issue on Linux Mint 20.2 Cinnamon.

@gustavo-iniguez-goya
Copy link
Collaborator

ok @mariomadproductions , do you have other system tray icons?

Could you kill the GUI (pkill opensnitch-ui), launch it from a terminal and paste the output? : $ /usr/bin/opensnitch-ui

@mariomadproductions
Copy link

Yes I do, and in fact OpenSnitch does appear in the tray on startup, but I have to click the icon or close the window to "minimise" it into the tray.

user@pc:~$ pkill opensnitch-ui
user@pc:~$ /usr/bin/opensnitch-ui
Loading translations: /usr/lib/python3/dist-packages/opensnitch/i18n locale: en_GB
new node connected, listening for client responses... /tmp/osui.sock

@gustavo-iniguez-goya
Copy link
Collaborator

mm, ok, it looks like Qt is not detecting that the panel is running. In this situation we assume that the systray icon has not been added, so we launch the GUI.

launching it from the terminal shows the GUI as well?

@mariomadproductions
Copy link

launching it from the terminal shows the GUI as well?

Actually, it seems that when I launch it from the terminal or GUI (menu) after login, it goes straight to the tray. Strange...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants