Skip to content

fix(app): second launch shows the window; keep running in the background when closed - #171

Open
schultz-dev0 wants to merge 2 commits into
mmaher88:masterfrom
schultz-dev0:fix/second-launch-shows-window
Open

schultz-dev0 wants to merge 2 commits into
mmaher88:masterfrom
schultz-dev0:fix/second-launch-shows-window

Conversation

@schultz-dev0

@schultz-dev0 schultz-dev0 commented Nov 3, 2026 •

Copy link
Copy Markdown

Closing the window doesn't close it. In src/app/qml/Main.qml:77-80, onClosing rejects the close and calls hide(), and setQuitOnLastWindowClosed(false) in src/app/main.cpp:60 keeps the process alive with no window. The next launch then fails lockFile.tryLock() in src/app/main.cpp:93-99, because the hidden instance still holds the lock. It logs "Another instance of Logitune is already running" and returns 1. If you're on a system with no tray, the only way to open the app again is to pkill it first.

The first commit keeps the QLockFile and adds a QLocalServer next to it in the first instance (src/app/SingleInstance.*). A second launch connects, sends a show command and exits with 0, and the window comes back up. The tray's "Show" and the second launch share the same code. The lock file moved from the temp directory to the per-user runtime directory, next to the new socket.

Since a second launch can now always bring the window back, the second commit makes Logitune keep running when its window is closed, tray or not:

  • Closing the window destroys the UI (src/app/MainWindowController.*). Devices, profiles, the tray and the single-instance server keep running.
  • A second launch, or the tray's "Show", builds the window again.
  • --minimized starts without building the window at all.
  • logitune --quit ends the running instance, and there's a Quit button in Settings, so you can quit without a tray. The tray's Quit stays.

Memory (PSS, Hyprland, after an 8 s settle): about 120 MiB with the window open, about 80 MiB after closing it (88 MiB after repeated open/close cycles, then flat), and about 32 MiB when started with --minimized. Closing frees the window's objects and calls malloc_trim(0) on glibc, but Qt keeps some caches once the UI has been built, so it doesn't get back down to the --minimized figure.

Tests: second launch sends show and exits 0; --quit reaches the primary and exits 0, and does nothing when no instance is running; closing destroys the window and a show request builds a new one; the Quit button quits. logitune-tests (762), logitune-tray-tests (9) and the QML tests (79) pass. Smoke-tested on Hyprland with and without a tray host: closing keeps the process, a second launch brings the window back, device notifications keep being handled with no window, and --quit ends it.

A second launch used to fail the instance lock and exit silently while the first instance sat hidden. It now asks the running instance to show its window and exits 0. Without a tray, closing the window quits instead of hiding.
Closing the window destroys the UI and keeps devices, profiles, the tray and the single-instance server running, with or without a tray. Launching again rebuilds the window. --minimized starts without building it at all. Add --quit and a Quit button in Settings so the app can be ended without a tray.
@schultz-dev0 schultz-dev0 changed the title fix(app): show the running window on a second launch fix(app): second launch shows the window; keep running in the background when closed Nov 3, 2026
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