pub enum MenuMode {
Auto,
Popup,
Dbusmenu,
}Expand description
Which way the right-click menus are served — the user’s choice, as
tray.toml holds it.
The popup (hyprforge-traymenu) is the suite’s own menu: themed like
the clipboard and emoji popups, anchored below the bar at the icon
that was clicked. It needs two things this daemon cannot assume. It
reads the monitors through hyprctl, so it only works on Hyprland.
And the bar has to call ContextMenu on an item that declares no
Menu property, which a bar that only draws dbusmenu never does —
on such a bar the popup is never even asked for.
com.canonical.dbusmenu is the fallback that works on any
spec-compliant bar and any compositor, drawn and placed however that
bar’s tray module chooses. It is the menu this crate served before the
popup existed, and it comes back as a choice rather than the default
because the popup is the better menu wherever it can run.
Auto, the default, picks the popup where it can run and dbusmenu
everywhere else, so installing the tray on sway gives right-click
menus with nothing configured. Popup and Dbusmenu force one —
Dbusmenu is for a bar on Hyprland that never calls ContextMenu,
which nothing here can detect from the outside.
Variants§
Implementations§
Source§impl MenuMode
impl MenuMode
Sourcepub fn serving(self, on_hyprland: bool, traymenu_installed: bool) -> MenuServing
pub fn serving(self, on_hyprland: bool, traymenu_installed: bool) -> MenuServing
The decision, as a pure function of what the machine offers.
on_hyprland and traymenu_installed are passed in rather than
looked up so every combination is testable without a compositor
or a $PATH — Self::serving_here is the one place that asks.
Sourcepub fn serving_here(self) -> MenuServing
pub fn serving_here(self) -> MenuServing
Self::serving, asked of this machine.
Hyprland sets HYPRLAND_INSTANCE_SIGNATURE for everything it
starts, and hyprctl — which the popup needs — reads the same
variable to find its socket, so its absence is exactly “the popup
cannot place itself”. Cheap enough for every poll tick: one
environment read and a stat per $PATH entry.