Skip to content

Linux: close to the system tray, and fix clip playback in the frozen bundle - #92

Open
Tinkus144Hz wants to merge 2 commits into
FTHR-Community:linux-2.0from
Tinkus144Hz:feat/linux-close-to-tray
Open

Tinkus144Hz wants to merge 2 commits into
FTHR-Community:linux-2.0from
Tinkus144Hz:feat/linux-close-to-tray

Conversation

@Tinkus144Hz

@Tinkus144Hz Tinkus144Hz commented Oct 21, 2026 •

Copy link
Copy Markdown

What does this PR do?

Lets FTHR keep running in the system tray on Linux when the main window is closed, and fixes clip playback in the frozen Linux bundle.

Why?

The close-to-tray lifecycle already existed in 2.0 but was gated to sys.platform == 'win32', so on Linux the window's X always went through the full shutdown path and stopped capture. Linux desktops with a StatusNotifierItem host (KDE, waybar, GNOME + AppIndicator extension, …) can host the existing QSystemTrayIcon just fine.

While testing a locally built bundle, opening any clip failed with PLAYBACK_STALLED / "No QtMultimedia backends found". That is independent of the tray change but blocks testing it in a packaged build, so it is included as a separate commit.

Changes

feat(linux): close to the system tray when a tray host is available (FTHR_UI/main.py)

  • New _close_to_tray_supported(): always true on Windows; on Linux true when QSystemTrayIcon.isSystemTrayAvailable().
  • Replaced the win32 gates with it in _create_system_tray, closeEvent, the title-bar power button, the settings checkbox and its toggle handler. Without a tray host, X still exits through request_full_exit() as before.
  • Wayland restore fix: restore_main_window() now unpauses the background UI before showing and resets _first_frame_painted when the window was hidden. Previously the window was still updates-disabled when shown, Wayland never got a first buffer so it never mapped the surface, the app therefore never became active, and the scheduled _refresh_background_ui_pause_state re-paused it — the window stayed invisible on the first restore. The immediate QTimer.singleShot(0, _refresh_background_ui_pause_state) in restore is dropped; showEvent and applicationStateChanged still drive later pause/unpause.

fix(build): bundle Qt Multimedia's FFmpeg stub libraries on Linux (FTHR_linux.spec)

  • The wheel's libavcodec.so.61 NEEDs libQt6FFmpegStub-{va,va-drm,va-x11,ssl,crypto}.so.* next to it (RUNPATH $ORIGIN). PyInstaller does not collect them, so libffmpegmediaplugin.so cannot load.
  • Collect them explicitly into PySide6/Qt/lib, and let them through _keep_reviewed_qt_runtime (they are part of the already approved Multimedia module; QT_SO_RE in verify_release_licenses.py does not count hyphenated names as separate modules, so the licence gate is unchanged).

Testing

Manual, on CachyOS / Hyprland (Wayland), waybar tray, NVENC:

  • Source run and locally built bundle: X hides the window, the engine keeps the same PID and keeps capturing, tray icon is registered (StatusNotifierItem). Tray click / tray "Open FTHR" / launching a second instance restores the window — 3 hide/restore cycles in a row.
  • --background start: no window, tray icon present, F9 saves a clip end to end ("Clip ready").
  • Bundle before the spec fix: ldd libffmpegmediaplugin.so reports the stubs as not found and playback stalls. After: no missing libraries, startup logs "Using Qt multimedia with FFmpeg 7.1.3", clips play.

Automated:

  • ruff check and tools/scan_repo_hygiene.py --staged clean
  • pytest tests/ on Linux: no new failures. The full run segfaults in tests/test_game_detection_popup.py (what fix/linux-2.0-test-segfaults addresses; it crashes the same way without this PR), so I ran each of the 160 test files in its own process and compared failing test IDs against unmodified linux-2.0: the same 33 tests in 14 files fail on both; none are added or fixed by this PR.
  • Tested manually on Windows — not tested; Windows behaviour should be unchanged since _close_to_tray_supported() is always true there.

Notes

  • build_linux.sh on this host stops at the glibc 2.35 baseline check (CachyOS ships glibc 2.4x), so I installed the AppDir instead of the AppImage. Not related to this PR.
  • Open questions for review: should the tray behaviour on Linux get its own setting default, or a hint in Settings when no tray host is available? Should the power button also show on Linux when no tray host exists (currently hidden, same as before)?
  • Written with help from an AI assistant (Claude); I tested the result on my machine.

Tinkus144Hz and others added 2 commits October 21, 2026 20:19
The close-to-tray lifecycle was gated to win32, so on Linux the window's
X always took the full shutdown path and stopped capture. Enable it
wherever QSystemTrayIcon reports a tray host (StatusNotifierItem on
KDE, waybar, GNOME with AppIndicator, ...). Without one, X still exits
through request_full_exit() as before.

On Wayland the first restore from the tray left the window invisible:
it was shown while background-paused (updates disabled), so no buffer
was committed, the compositor never mapped it, the app never became
active, and the scheduled pause refresh kept it paused. Unpause before
showing and defer re-pausing until the restored surface painted once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The wheel's libavcodec.so.61 needs libQt6FFmpegStub-{va,va-drm,va-x11,
ssl,crypto} next to it (RUNPATH $ORIGIN). PyInstaller does not collect
them and the reviewed-Qt filter dropped them, so libffmpegmediaplugin.so
failed to load: "No QtMultimedia backends found" and every clip stalled
with PLAYBACK_STALLED in the frozen bundle. Collect them explicitly and
let them through the filter as part of the approved Multimedia module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant