Skip to content

If there's no system tray, at least show a window. #2205

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

daym
Copy link

@daym daym commented Feb 15, 2025

  • src/vorta/application.py: Check whether system tray is available.

Fixes #2204.

Description

Related Issue

#2204

Motivation and Context

vorta should provides a means of interaction for the user even if the system tray is unavailable.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read the CONTRIBUTING guide.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.

* src/vorta/application.py: Check whether system tray is available.

Fixes <borgbase#2204>.
@m3nu
Copy link
Contributor

m3nu commented Feb 15, 2025

Hi, thanks for the PR!

So this opens the main window, if no system tray is available?

How about changing the foreground setting we already have to be enabled, if no system tray is there?

@daym
Copy link
Author

daym commented Mar 30, 2025

So this opens the main window, if no system tray is available?

Yes.

How about changing the foreground setting we already have to be enabled, if no system tray is there?

It's your choice--but it's a user setting so I wouldn't expect it to be auto-changed. What if you just used vorta in vnc for a minute (so systray was unavailable for a minute) but systray is now available again? I would be miffed if that enabled the setting permanently.

@VandalByte
Copy link
Collaborator

I tested this issue using the flatpak version of vorta 0.10.3 on MX Linux (XFCE). To investigate the behavior, I created a small script:

from PyQt6.QtWidgets import QApplication, QSystemTrayIcon
import sys

app = QApplication(sys.argv)
tray_available = QSystemTrayIcon.isSystemTrayAvailable()
print("System tray available:", tray_available)
sys.exit()

I removed the system tray from the panel and ran the script. The output was: System tray available: False. Then I ran the vorta app and it seems to work fine as expected, when there was no system tray the window did open up. I even tried with removing the whole XFCE panel and seems to work fine as expected. So when no tray available, vorta seems to fall back to main window.

I didn't see any errors like you mentioned in your issue #2204, even without system tray vorta is running fine, so maybe this is an isolated incident?

Unrelated to this issue
One another potential issue that I discovered is, if the setting Show main window of vorta on launch is unchecked (which is checked by default) by the user, then if there's no system tray, the app will just run the background without showing a window.

@daym
Copy link
Author

daym commented Apr 29, 2025

I didn't see any errors like you mentioned in your issue #2204, even without system tray vorta is running fine, so maybe this is an isolated incident?

I don't know.

Did you see this part?

qt.core.qobject.connect: QObject::connect: No such signal QPlatformNativeInterface::systemTrayWindowChanged(QScreen*)

So I think maybe also remove the connect to systemTrayWindowChanged for testing it, please.

For comparison, I use wayland and vulkan and in general 2025 technology on the computer this happened on. I have no idea whether it would happen on Xorg or gdk-pixbuf or similar.

In general, I didn't dig into this because I had too much time on my hands but rather because I couldn't get to my backups at all, again and again, for more than a week.

I carry a local vorta patch that gets auto-applied on every update, so whether or not the patch lands upstream I don't care so much. That said, if you want to get to the bottom of this, we can.

If you look at the source code, I don't understand how, in your case, it could present the main window if no one ever calls self.open_main_window_action. Seems strange to me. Could you please add

import traceback
traceback.print_stack()

to the body of open_main_window_action and see who it is that calls it?

@VandalByte
Copy link
Collaborator

VandalByte commented Apr 30, 2025

Did you see this part?

qt.core.qobject.connect: QObject::connect: No such signal QPlatformNativeInterface::systemTrayWindowChanged(QScreen*)

Yes, I did and I'm not sure about what error PyQt throws when there's no tray available but this looks like a signal not found issue. I googled the same and I saw this mentioned in stackoverflow as a PyQt5 issue:

The "screenRemoved" is a singnal from "QGuiApplication".
And "QApplication" iherits "QGuiApplication".
It is all good. But this method is there from Qt5.4 version.
http://doc.qt.io/qt-5/qguiapplication.html#screenRemoved
Please check your QT version. May be it is bit older.

But we use PyQt6 so I'm not sure why this would be happening. I also found the same in an old vorta's issue. Also I found this in an archwiki:

Solved. The problem was that for whatever reason QT_QPA_PLATFORM was getting set to 'offscreen'.

Here's the stacktrace (I added the system tray check in the code):

2025-04-30 18:33:27,695 - vorta.application - INFO - System tray available?: False
  File "/home/vandal/Code/vorta/env/bin/vorta", line 8, in <module>
    sys.exit(main())
  File "/home/vandal/Code/vorta/src/vorta/__main__.py", line 79, in main
    app = VortaApp(sys.argv, single_app=args.profile is None)
  File "/home/vandal/Code/vorta/src/vorta/application.py", line 80, in __init__
    self.open_main_window_action()
  File "/home/vandal/Code/vorta/src/vorta/application.py", line 133, in open_main_window_action
    traceback.print_stack()

This env variable QT_QPA_PLATFORM was used a lot in the issue as well, can you try setting export QT_QPA_PLATFORM=wayland. First answer here has more info on the available values.

@daym
Copy link
Author

daym commented May 2, 2025

Ok, so open_main_window_action is called when the setting "Show main window of Vorta on launch" is set.

But in my case I have not set that setting for several months (years?)--that is, the setting is not eabled. Now, the tray became unavailable and then I couldn't enter vorta anymore, not even to set that setting.

What the patch here would do is in that case force showing something anyway, for now. (The setting is not changed since if the tray becomes available again, the user presumably still doesn't want the main window to open automatically, as the user indicated)

@daym
Copy link
Author

daym commented May 2, 2025

Aha, easy way to reproduce is QT_QPA_PLATFORM=vkkhrdisplay vorta.

Also QT_QPA_PLATFORM=vnc vorta.

@VandalByte
Copy link
Collaborator

VandalByte commented May 3, 2025

So there are two issues here, one the error you are getting, second the functionality issue you mentioned regarding the setting "Show main window of vorta on launch".

First: Error issue
In my case the env variable was not set at all. I was able to reproduce your error for QT_QPA_PLATFORM=vkkhrdisplay (WITH and WITHOUT the system tray) but not for vnc, since you are using wayland can you check and tell us if you are getting those errors after setting export QT_QPA_PLATFORM=wayland in your ~/.bashrc (or the one you use), if it doesn't work try with export QT_QPA_PLATFORM=xcb, both of these seems to support vulkan via via QVulkan api.

PS: Don't forget to source ~/.bashrc, I have forgotten, many times...

Second: Unavailability of vorta window
You addition via this PR, fixes the issue I mentioned above:

One another potential issue that I discovered is, if the setting Show main window of vorta on launch is unchecked (which is checked by default) by the user, then if there's no system tray, the app will just run the background without showing a window.

Without a system tray, user doesn't seem to have an option to open the window to even switch the setting back.

I have tested out the new addition with all the possibilities, and everything seems to work as expected. Please let us know about the error issue, so that we can move this forward.

@daym
Copy link
Author

daym commented May 3, 2025

$ export QT_QPA_PLATFORM=wayland
$ vorta
2025-05-03 22:33:08,471 - vorta.i18n - DEBUG - Loading translation succeeded for ['en-Latn-US', 'en-US', 'en'].
2025-05-03 22:33:08,684 - root - INFO - Using NetworkManagerMonitor NetworkStatusMonitor implementation.
2025-05-03 22:33:08,813 - vorta.borg.jobs_manager - DEBUG - Add job for site default
2025-05-03 22:33:08,813 - vorta.borg.jobs_manager - DEBUG - Start job on site: default
2025-05-03 22:33:08,823 - vorta.borg.borg_job - INFO - Running command /gnu/store/hfdxapi324pj8nb6kcldrhgibx3s1qx6-borg-1.4.1/bin/borg --version
2025-05-03 22:33:09,355 - vorta.borg.jobs_manager - DEBUG - Finish job for site: default
2025-05-03 22:33:09,355 - vorta.borg.jobs_manager - DEBUG - No more jobs for site: default
2025-05-03 22:33:09,355 - vorta.scheduler - DEBUG - Refreshing all scheduler timers
$ export QT_QPA_PLATFORM=xcb
$ vorta
2025-05-03 22:47:18,872 - vorta.i18n - DEBUG - Loading translation succeeded for ['en-Latn-US', 'en-US', 'en'].
2025-05-03 22:47:19,031 - root - INFO - Using NetworkManagerMonitor NetworkStatusMonitor implementation.
2025-05-03 22:47:19,147 - vorta.borg.jobs_manager - DEBUG - Add job for site default
2025-05-03 22:47:19,148 - vorta.borg.jobs_manager - DEBUG - Start job on site: default
2025-05-03 22:47:19,156 - vorta.borg.borg_job - INFO - Running command /gnu/store/hfdxapi324pj8nb6kcldrhgibx3s1qx6-borg-1.4.1/bin/borg --version
2025-05-03 22:47:19,517 - vorta.borg.jobs_manager - DEBUG - Finish job for site: default
2025-05-03 22:47:19,517 - vorta.scheduler - DEBUG - Refreshing all scheduler timers
2025-05-03 22:47:19,517 - vorta.borg.jobs_manager - DEBUG - No more jobs for site: default

In both cases, a tray icon shows up.

Next, I'll try with intentionally killed tray.

$ pkill waybar
$ export QT_QPA_PLATFORM=wayland
$ vorta
2025-05-03 22:36:16,534 - vorta.i18n - DEBUG - Loading translation succeeded for ['en-Latn-US', 'en-US', 'en'].
2025-05-03 22:36:16,703 - root - INFO - Using NetworkManagerMonitor NetworkStatusMonitor implementation.
2025-05-03 22:36:16,846 - vorta.borg.jobs_manager - DEBUG - Add job for site default
2025-05-03 22:36:16,846 - vorta.borg.jobs_manager - DEBUG - Start job on site: default
QDBusTrayIcon encountered a D-Bus error: QDBusError("org.freedesktop.DBus.Error.ServiceUnknown", "The name org.kde.StatusNotifierWatcher was not provided by any .service files")
2025-05-03 22:36:16,854 - vorta.borg.borg_job - INFO - Running command /gnu/store/hfdxapi324pj8nb6kcldrhgibx3s1qx6-borg-1.4.1/bin/borg --version
2025-05-03 22:36:17,251 - vorta.borg.jobs_manager - DEBUG - Finish job for site: default
2025-05-03 22:36:17,252 - vorta.scheduler - DEBUG - Refreshing all scheduler timers
2025-05-03 22:36:17,252 - vorta.borg.jobs_manager - DEBUG - No more jobs for site: default
2025-05-03 22:36:30,834 - vorta.borg.borg_job - DEBUG - Cancel job on site default
2025-05-03 22:36:30,834 - vorta.borg.jobs_manager - INFO - Finished cancelling all jobs
$ pkill waybar
$ export QT_QPA_PLATFORM=xcb
$ vorta
2025-05-03 22:38:45,588 - vorta.i18n - DEBUG - Loading translation succeeded for ['en-Latn-US', 'en-US', 'en'].
2025-05-03 22:38:45,772 - root - INFO - Using NetworkManagerMonitor NetworkStatusMonitor implementation.
2025-05-03 22:38:45,896 - vorta.borg.jobs_manager - DEBUG - Add job for site default
2025-05-03 22:38:45,896 - vorta.borg.jobs_manager - DEBUG - Start job on site: default
2025-05-03 22:38:45,904 - vorta.borg.borg_job - INFO - Running command /gnu/store/hfdxapi324pj8nb6kcldrhgibx3s1qx6-borg-1.4.1/bin/borg --version
2025-05-03 22:38:46,268 - vorta.borg.jobs_manager - DEBUG - Finish job for site: default
2025-05-03 22:38:46,269 - vorta.scheduler - DEBUG - Refreshing all scheduler timers
2025-05-03 22:38:46,269 - vorta.borg.jobs_manager - DEBUG - No more jobs for site: default

The "qt.core.qobject.connect: QObject::connect: No such signal QPlatformNativeInterface::systemTrayWindowChanged(QScreen*)" doesn't seem to show up above.

$ pkill waybar
$ export QT_QPA_PLATFORM=vkkhrdisplay
$ vorta
2025-05-03 22:43:15,390 - vorta.i18n - DEBUG - Loading translation succeeded for ['en-Latn-US', 'en-US', 'en'].
qt.core.qobject.connect: QObject::connect: No such signal QPlatformNativeInterface::systemTrayWindowChanged(QScreen*)
2025-05-03 22:43:15,558 - root - INFO - Using NetworkManagerMonitor NetworkStatusMonitor implementation.
2025-05-03 22:43:15,674 - vorta.borg.jobs_manager - DEBUG - Add job for site default
2025-05-03 22:43:15,675 - vorta.borg.jobs_manager - DEBUG - Start job on site: default
2025-05-03 22:43:15,683 - vorta.borg.borg_job - INFO - Running command /gnu/store/hfdxapi324pj8nb6kcldrhgibx3s1qx6-borg-1.4.1/bin/borg --version
2025-05-03 22:43:16,032 - vorta.borg.jobs_manager - DEBUG - Finish job for site: default
2025-05-03 22:43:16,033 - vorta.scheduler - DEBUG - Refreshing all scheduler timers
2025-05-03 22:43:16,033 - vorta.borg.jobs_manager - DEBUG - No more jobs for site: default

In the three latter cases (listed before here) it's not possible to get into vorta at all as a user.

@VandalByte
Copy link
Collaborator

VandalByte commented May 4, 2025

Thanks! It seems like the error is an isolated issue related to the individual desktop environment. I don't think there's much we can do to solve it, especially since, as I mentioned, the variable wasn't even set in my case. Also we shouldn't forcibly set any unnecessary environment variables on users' systems.

That said, this PR does fix an annoying issue by giving users a way to use Vorta when the Show main window of Vorta on launch setting is unchecked and the system tray is unavailable.

@VandalByte VandalByte requested a review from m3nu May 4, 2025 00:23
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

Successfully merging this pull request may close these issues.

vorta isn't usable if system tray is unavailable
3 participants