Skip to content

friglet-tray: left click opens the window; top-bar popup on Hyprland/Omarchy (SNB-656) - #39

Merged
setavenger merged 1 commit into
integrationfrom
snb-656-tray-omarchy-popup
Oct 2, 2026
Merged

setavenger merged 1 commit into
integrationfrom
snb-656-tray-omarchy-popup

Conversation

@setavenger

@setavenger setavenger commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Fixes SNB-656: on Omarchy 4 (Hyprland, Quickshell bar) a left click on the friglet-tray icon did nothing, and the status window opened as an ordinary tiled window.

Stacked on #37 (snb-658-tray-controls-errors-logs), which reworks friglet-tray heavily. The branch starts at #37's head (10a15b0). #37 merged into integration (017131a) while this was in progress and its branch was deleted, so this PR targets integration directly. It merges cleanly with the current integration, which also contains #34–#36.

Why left click did nothing

Tauri's tray uses tray-icon's libappindicator backend on Linux. libayatana never exports ItemIsMenu, and it rejects Activate when no handler is connected. Omarchy's bar sends Activate(0, 0) on a left click unless the item is menu-only (shell/plugins/bar/widgets/Tray.qml:832-841), so the click was dropped. blindbit-desktop (fyne.io/systray) gets clicks differently: it implements StatusNotifierItem itself over D-Bus. With no tap handler it sets ItemIsMenu=true, so a left click there opens its menu.

Changes

  • Tray icon (Linux): KSNI backend. friglet-tray/Cargo.toml turns on tray-icon's ksni feature. Tauri still enables libappindicator; when both are on, tray-icon uses KSNI.
    • The item exports ItemIsMenu=false, so a host sends a left click as Activate. That arrives as TrayIconEvent::Click { Left, Up }.
    • The menu stays on right click (dbusmenu). Live label and enablement updates still reach it.
  • Left click. Under Hyprland it toggles the popup. Everywhere else it opens the ordinary window: Linux desktops, plus macOS and Windows, where show_menu_on_left_click is now false so the menu is on right click there too.
  • No StatusNotifierWatcher at startup. This happens when the tray starts before the bar at login, or on a desktop without an SNI tray. KSNI then fails to register, and building the tray returned an error from setup. The tray now logs a warning, keeps running and retries every 2 s, doubling up to 30 s. The status poller looks the icon up by id, so an icon that appears late gets its tooltip.
  • Hyprland popup mode (new friglet-tray/src/popup.rs). It is on only when HYPRLAND_INSTANCE_SIGNATURE is set and talks to $XDG_RUNTIME_DIR/hypr/$SIG/.socket.sock directly. It writes no config files.
    • Window. Undecorated and fixed at 420×600 (min = max), which Hyprland floats even if every IPC call fails. GTK's non-resizable mode sized the window to its content (420×800 in testing), so it is not used.
    • Placement. Before each show the tray reads j/cursorpos, j/monitors (bar height from reserved[1]) and general:gaps_out. The panel goes right-aligned, gaps_out / 2 below the bar and from the right edge, which is the geometry of Omarchy's KeyboardPanel. It shrinks on short screens.
    • Pre-show rule (Lua API, Hyprland 0.55+). eval registers hl.window_rule({ match = { title, class? }, float, size, move = { "(monitor_w-window_w-N)", top } }), so the window maps in place. The previous rule is disabled first, Omarchy's omarchy-launch-about pattern: Hyprland has no rule removal, and re-registering a named rule appends effects. The rule is only re-sent when it changes.
    • Hover rule. While the popup is open, a second rule gives every other window no_follow_mouse. Omarchy sets follow_mouse = 1, so without it, moving the pointer off the popup would focus the window underneath and close the popup. A click still moves focus (InputManager.cpp:704-707, 897-912 at Hyprland 586c01e). Hiding, Esc, quit and the next start all turn the rule off.
    • After the show. The tray finds its window in j/clients by PID and learns its class. That class goes into later rules and is logged at info: "Hyprland window class of the status window". If the window is not where planned, the tray floats, resizes and moves it with hl.dsp.window.*, or with the legacy setfloating/resizewindowpixel/movewindowpixel dispatchers when Hyprland has no Lua API.
    • Closing.
      • A second left click closes it.
      • Esc closes it. The page acts on the key release of a press it saw. Hiding on the press cut the keystroke in half, and under Xvfb WebKitGTK delivered the press again on the next show, which closed the popup at once.
      • Focus loss closes it, after a 150 ms settle and a check of j/activewindow: a dropdown of ours, the network <select>, leaves our window active in Hyprland.
      • A click that caused the focus loss does not reopen the popup.
  • README: a note on the Linux tray (needs an SNI host; XEmbed-only trays no longer show it) and an Omarchy/Hyprland section, including an optional static rule in Omarchy 4's Lua syntax. AGENTS.md: the headless tray notes are updated for KSNI.

Verification

All builds were debug builds.

  • cargo test --workspace passed. friglet-tray now has 67 unit tests (16 new in popup.rs) plus 9 e2e.

  • cargo clippy --no-deps -p friglet-ipc -p friglet-tray --all-targets -- -D warnings is clean (the CI lint, minus friglet, which this PR does not touch), and cargo fmt -p friglet-tray -- --check passes.

  • Unit tests against a fake Hyprland socket. The fake reads each request to EOF, records it and answers like Hyprland. The tests cover:

    • the exact request sequence and rule text on a Lua Hyprland;
    • no dispatch when the rule placed the window;
    • the class being learned, then added to the rule, and an unchanged rule not being re-sent;
    • Lua dispatchers for a misplaced window;
    • a pre-Lua Hyprland (eval is only supported with the lua config manager), which gets the legacy dispatchers only and no further eval;
    • the active-window check;
    • no socket at all.

    Pure tests cover placement (scale, transform, monitor offset, reserved right edge, small screens), the css and custom gap replies and escaping.

  • End to end under Xvfb. The setup was a private D-Bus session, a stand-in StatusNotifierWatcher and host that follows Omarchy's Tray.qml click rules (left: Activate unless ItemIsMenu; right: dbusmenu), the fake daemon, and a fake Hyprland socket that applies rules and dispatches to the X11 windows with xdotool. Clicks were real X pointer clicks on the stand-in tray icon.

    • Plain (no Hyprland). ItemIsMenu=False. Left click → Activate → the window opens. A second left click keeps it open. Right click shows the menu. "Start scanning" from the menu works, and the menu then shows Start disabled and Stop enabled.
    • Hyprland mode.
      • Left click → popup at 855,33, 420×600 on a 1280×800 screen with a 28 px bar and gaps_out 10.
      • Left click → hidden. Left click → shown. Esc → hidden. Left click → shown.
      • Focus moved to another window → hidden.
      • A later left click → shown.
      • Hidden, then "Open Status Window" from the right-click menu → popup in place.
      • Right-click menu and "Start scanning" work.
    • Pre-Lua Hyprland. The popup is placed by the legacy dispatchers, and the toggle works.
    • Fake that ignores rules and dispatches. The window is 420×600 by itself, and the Lua dispatch fallback is sent.
    • Tray started with no watcher, host started 6 s later: a warning, then "tray icon registered", and left click works.

Not verified

  • On a real Hyprland/Omarchy session (none available here). The Lua rule and dispatch syntax, move semantics and reply strings come from Hyprland's source at 586c01e and v0.56.2 and from Omarchy quattro @ c05d901, but nothing ran against a live compositor. Unverified there:
    • that hl.window_rule accepts exactly these tables;
    • the hover rule's effect;
    • the focus-loss timing;
    • the window class: expected friglet-tray, logged at runtime.
  • The click behaviour on GNOME (AppIndicator extension) and KDE was not run. They now get a KSNI item with ItemIsMenu=false.
  • XEmbed-only trays (no SNI watcher, e.g. a bare i3bar) no longer show the icon, where libappindicator fell back to XEmbed.
  • The macOS and Windows behaviour was not run; those builds were only compiled and bundled. This PR's CI built them: the test job and the Linux, macOS (universal dmg) and Windows (msi/nsis) packaging jobs are green. The new socket code is cfg(unix), with a stub otherwise.

…(SNB-656)

- Linux tray uses tray-icon's KSNI backend: the item exports
  ItemIsMenu=false, so SNI hosts (Omarchy's bar, KDE, ...) send a left
  click as Activate; the menu stays on right click. macOS/Windows: menu on
  right click only. Left click opens the window everywhere.
- No StatusNotifierWatcher at startup (tray before the bar at login): the
  tray keeps running and retries the icon (2 s doubling to 30 s) instead of
  failing setup.
- Under Hyprland (HYPRLAND_INSTANCE_SIGNATURE) the window is a popup:
  undecorated, fixed 420x600 (min = max), right-aligned gaps_out/2 under
  the bar. Before each show a Lua window rule is registered over the IPC
  socket so it maps in place; after the show it is checked in j/clients
  (class learned and logged) and moved by dispatch if needed (legacy
  dispatchers without the Lua API). Left click toggles; Esc and focus loss
  hide. While open, other windows get no_follow_mouse so hovering them
  (Omarchy: follow_mouse = 1) does not steal focus and close the popup.
- README: Linux tray note and an Omarchy/Hyprland section with an optional
  static rule; AGENTS.md headless tray notes updated for KSNI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@setavenger
setavenger merged commit af9e7cb into integration Oct 2, 2026
5 checks passed
@setavenger
setavenger deleted the snb-656-tray-omarchy-popup branch October 2, 2026 14:47
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