Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,21 @@ dbus-run-session -- bash -c '
init is flaky. The tray and `gtk-sni-tray-standalone` must share that bus.
- Tray icon: bare Xvfb has no StatusNotifierWatcher. With
`gtk-sni-tray-standalone -w` (package `haskell-gtk-sni-tray-utils`) under
fluxbox the friglet SNI icon renders (ayatana path
`/org/ayatana/NotificationItem/tray_icon_tray_app_friglet_tray`).
fluxbox the friglet SNI icon renders. Since SNB-656 the Linux tray is
tray-icon's KSNI backend (feature `ksni` in `friglet-tray/Cargo.toml`), not
libayatana: bus name `org.kde.StatusNotifierItem-<pid>-<n>`, object
`/StatusNotifierItem`, `ItemIsMenu=false`, menu at `/MenuBar`. A host's
left click is `Activate` (toggles the window), right click opens the menu;
e.g. `gdbus call --session -d <name> -o /StatusNotifierItem -m
org.kde.StatusNotifierItem.Activate 0 0`. Without a watcher the tray keeps
running and retries the icon (2 s, doubling to 30 s).
`snixembed` is not in Ubuntu apt; `trayer` alone only hosts legacy XEmbed
icons, not StatusNotifierItem. xdotool clicks do not reach WebKitGTK under
Xvfb — use `FRIGLET_TRAY_SHOW_ON_START=settings` for the Settings form.
- Hyprland popup mode (`friglet-tray/src/popup.rs`) is on whenever
`HYPRLAND_INSTANCE_SIGNATURE` is set; its socket logic is unit-tested
against a fake `.socket.sock` in that file. Keep the socket path under
108 bytes (`sun_path`) when faking `XDG_RUNTIME_DIR`.

## Packaging (M4)

Expand Down
35 changes: 35 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 49 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ What to expect from it:
`friglet-tray` is a small Tauri v2 system tray app that supervises and
monitors the `friglet` daemon over its control socket. It shows live status
(scan height, progress, network, Electrum clients, oracle connectivity, SP
address, errors) in the tray menu and in a status window (hidden by default,
opened via the tray menu; closing it hides it again). The tray menu and the
address, errors) in the tray menu and in a status window (hidden by default;
a left click on the tray icon opens it, and so does **Open Status Window** in
the icon's right-click menu; closing it hides it again). The tray menu and the
Status tab offer Start/Stop scanning, Start/Stop daemon and Quit; a button
or menu item is only enabled when it does what it says (Start scanning is
greyed out while a scan runs, Stop daemon while none is running).
Expand Down Expand Up @@ -220,6 +221,51 @@ The **Wallet** tab is a read-only convenience view, not a spending wallet. It
shows found transaction/output counts plus copyable base and per-label Silent
Payments addresses.

**Tray icon on Linux.** The icon is a StatusNotifierItem (KSNI over D-Bus), so
it needs a desktop with an SNI tray: Omarchy's bar, KDE Plasma, GNOME with
the AppIndicator extension, Waybar's `tray` module and the like. Trays that
only host legacy XEmbed icons do not show it. When no tray is up yet (the
tray app started before the bar at login) the app keeps running and
registers the icon as soon as one appears.

**Omarchy / Hyprland: top-bar popup.** Under Hyprland (detected by
`HYPRLAND_INSTANCE_SIGNATURE`; Omarchy 4 runs it) the window opens like
Omarchy's own Wi-Fi and Bluetooth panels: floating, right-aligned just under
the top bar, without a title bar, at a fixed 420×600 (smaller on a short
screen). A left click on the tray icon opens it and a second one closes it;
Esc closes it, and so does focusing another window (clicking it, or a
keybinding). Merely moving the pointer over another window does not, although
Omarchy focuses windows on hover. The right-click menu is unchanged.

How: before each show the tray asks Hyprland, over its IPC socket, for the
monitor under the pointer, the bar height (the monitor's reserved top) and
`general:gaps_out`, and registers a window rule for its own window with the
Lua API (`hl.window_rule`, Hyprland 0.55+): float, size, and a position
`gaps_out / 2` below the bar and from the right edge. While the popup is open
a second rule sets `no_follow_mouse` on every other window, so hovering them
does not take the focus; hiding the popup turns it off. After the show the
tray checks where the window landed (`hyprctl clients`) and moves it with
dispatchers if it is off, which is also the only placement on a Hyprland
without the Lua API. Nothing is written to your config files. Everywhere
else (GNOME, KDE, other compositors, macOS, Windows) the window is the
ordinary one: a left click on the icon opens it, the menu is on right click.

If the tray runs without Hyprland's environment (say from a service that
lacks `HYPRLAND_INSTANCE_SIGNATURE`) it opens the ordinary window. A static
rule at the end of `~/.config/hypr/hyprland.lua` still floats it under the
bar (Omarchy 4 syntax, as in Omarchy's own rules; `31` is Omarchy's default
26 px bar plus a 5 px gap). The class is expected to be `friglet-tray`; the
tray logs the one Hyprland reports in popup mode (`Hyprland window class of
the status window` in `friglet-tray.log`), and `hyprctl clients` shows it:

```lua
o.window({ class = "^friglet-tray$", title = "^Friglet Status$" }, {
float = true,
size = { 420, 600 },
move = { "(monitor_w-window_w-5)", 31 },
})
```

```bash
# build (Linux needs the Tauri v2 system deps: libwebkit2gtk-4.1-dev,
# libayatana-appindicator3-dev, librsvg2-dev, libgtk-3-dev)
Expand All @@ -229,7 +275,7 @@ cargo build --release -p friglet-tray
./target/release/friglet-tray

# optional: show the status window immediately (normally hidden until
# opened from the tray menu — useful for headless / screenshot testing).
# opened from the tray icon — useful for headless / screenshot testing).
# Values: 1/true/yes/on/status → Status tab; settings → Settings tab;
# wallet → Wallet tab.
FRIGLET_TRAY_SHOW_ON_START=1 ./target/release/friglet-tray
Expand Down
8 changes: 8 additions & 0 deletions friglet-tray/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,13 @@ tauri-plugin-clipboard-manager = "2.3.2"
tauri-plugin-single-instance = "2"
tauri-plugin-autostart = "2"

# Linux: route tray-icon to its KSNI (StatusNotifierItem over D-Bus) backend.
# Tauri enables the libappindicator backend, which never reports clicks
# (libayatana rejects `Activate`), so a left click on the icon did nothing.
# With both features on, tray-icon uses KSNI: `ItemIsMenu=false`, left click
# arrives as `TrayIconEvent::Click`, right click still opens the menu.
[target.'cfg(target_os = "linux")'.dependencies]
tray-icon = { version = "0.25", default-features = false, features = ["ksni"] }

[dev-dependencies]
tokio = { version = "1.48.0", features = ["full"] }
Loading
Loading