hyprforge_tray/lib.rs
1//! Tray icons for the Hyprforge suite, over `org.kde.StatusNotifierItem`.
2//!
3//! A tray icon is a D-Bus object, not a toolkit widget. That is what makes
4//! this possible inside a suite that forbids GTK and Qt everywhere: the
5//! icon is a *name*, resolved by whichever bar is running against the
6//! user's own icon theme, and this crate owns no pixels at all.
7//!
8//! The library half knows nothing about Wi-Fi or Bluetooth — it is the
9//! protocol and the item model. `src/bin/trayd.rs` is what joins it to
10//! `hyprforge-network`, `hyprforge-bluetooth`, `hyprforge-power`,
11//! hyprsunset and `hyprforge-displayd` — see its own module doc.
12//!
13//! # Two ways to serve a right-click menu
14//!
15//! The menu is drawn by `hyprforge-traymenu`, a sibling `PopupApp`
16//! binary that this crate's `ItemInterface::context_menu` (in `sni.rs`)
17//! spawns and hands the menu to over a pipe — see `launch`'s own module
18//! doc for the whole sequence. That is what makes the menu themed like
19//! the rest of the suite, anchored below the bar at the icon that was
20//! clicked, with a configurable offset — none of which
21//! `com.canonical.dbusmenu` gives a daemon any say over, since drawing
22//! and positioning are entirely the host's job under that protocol.
23//!
24//! The popup needs Hyprland (it reads the monitors through `hyprctl`) and
25//! a bar that calls `ContextMenu` on an item that declares no `Menu`
26//! property. Where either is missing, this crate serves
27//! `com.canonical.dbusmenu` instead ([`dbusmenu`]), and the bar draws the
28//! menu itself, styled and placed however its tray module chooses. Which
29//! one is a `tray.toml` choice, `auto` by default — see
30//! [`prefs::MenuMode`]. An earlier version served only the popup, so a bar
31//! on another compositor showed icons with no menu at all; every
32//! component of this suite has to work with its siblings, and its
33//! compositor, absent.
34//!
35//! `menu` and `item` are the plain-data model of what a menu and an item
36//! are, with no D-Bus in sight. Both paths serve the same `Menu`, with the
37//! same row ids and the same action strings, and `hyprforge-traymenu`
38//! depends on this crate for exactly those two modules.
39
40pub mod dbusmenu;
41pub mod item;
42pub mod launch;
43pub mod menu;
44pub mod prefs;
45pub mod sni;
46
47pub use launch::OPENED_PREFIX;
48pub use prefs::{MenuMode, MenuServing, Prefs};
49pub use item::{Category, Status, TrayItem};
50pub use sni::{watcher_present, TrayError, TrayIcon};