Files
glassMxrph/docs/architecture.md
T
mxandClaude Opus 5.5 b3076a4cde Add an Emoji Picker as a launcher mode with a searchable grid
The launcher gains an emoji mode like Clipboard History: >emoji switches in
place without closing or animating, and glassmxrph emoji toggles it. Emoji
show as a grid instead of named rows; the selected or hovered emoji's name is
the section label. Search requires every term and ranks name matches before
keyword matches; Enter copies with wl-copy.

assets/emoji.tsv comes from Unicode 17 emoji-test.txt without skin-tone
variants, with keywords from the rofi emopicker list (scripts/emoji-data).
The test driver caps snapshot results, since IPC replies have a size limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 23:47:14 +02:00

167 lines
11 KiB
Markdown

# Architecture
`shell.qml` composes modules and exposes IPC; it contains no feature layout.
Directory singletons use explicit `qmldir` registration.
- `services/ConfigService.qml`: XDG persistence, defaults and validation.
- `services/ConfigLogic.js`: pure merge/validation/update functions, tested separately.
- `theme/ThemeManager.qml`: resolves custom, Qt system and Matugen accent sources.
- `theme/Theme.qml`: semantic color, shape and motion tokens. Literal theme colors live here.
- `theme/MatugenService.qml`: watches validated JSON; retains the last valid palette.
- `core/ShellState.qml`: settings routing and active-monitor selection.
- `core/ModuleRegistry.qml`: allowlisted bar component URLs; configuration cannot load arbitrary QML.
- `components/`: reusable glass primitives.
- `bar/`: ordered modules, assigned through configuration to left/center/right.
- `settings/`: appearance, tray, dock and about pages.
Phase 1 directly consumes the single native Hyprland model: no subprocess polling.
Later services encapsulate media, applications, networking and metrics for all views.
Desktop widgets are user-placed (`widgets/`); none are shown by default. Dock defaults to bottom.
Unknown configuration keys survive saves. Arrays preserve user order rather than
index-merging defaults. Future schema migrations must be explicit, tested and must
not silently replace pinned apps or configured module arrays. Unknown future schema
versions are rejected without overwriting the file.
Distribution boundaries: QML contains no package manager, host name, monitor name,
or machine path. Packaging lives under `packaging/`; ZaneyOS selection belongs in
the user's external repository. Optional capabilities must degrade visibly and safely.
Future palette generation: wallpaper event → debounced Matugen job → validate staging
JSON → atomic promotion → FileView reload → ThemeManager. One global palette follows
a configured monitor. Job generations prevent stale jobs replacing newer requests.
Current music artwork must never change the global accent.
## Phase 2 tray
`TrayService` owns the one native `SystemTray` model, active icon/menu, hover dismissal
and popup registry. `TrayModule` renders only registered SNI items on each bar.
`TrayMenus` owns one root popup and a Hyprland focus grab for outside dismissal.
Each submenu uses a lazily instantiated `QsMenuOpener` and an anchored popup; dormant
menus do not retain openers or animation timers. Compositor constraints flip/slide
popups at screen edges. The menu stack is closed when its tray delegate disappears
or Settings opens. Tray clicks never call the system-area action.
`GlassMenu` and `GlassMenuItem` are shared presentation components. `TrayMenuItem`
adapts real `QsMenuEntry` state; triggering calls the entry's actual `triggered()`
signal. The app remains authoritative for checked state. Empty/asynchronous menus
show status text, not made-up application actions.
The optional `GLASSMXRPH_TESTING=1` driver imports QtTest for event simulation on
fixture icons. It is unloaded in normal operation; QtTest is not a runtime dependency.
The fixture runs in a private DBus session and never activates real user applications.
## Phase 3 dock
`ApplicationsService` owns the shared native desktop-entry catalog and launches.
`HyprlandService` adapts the one native toplevel model; focus/close use Wayland
handles with validated Hyprland address dispatch as fallback.
`AppMatching.js` and `DockGeometry.js` contain independently tested pure logic.
`DockModel` groups windows and saved pins; keyed ScriptModel delegates preserve
icon identity when focus or geometry changes. `DockState` owns the single chooser/
context popup and coordinates exclusivity with tray menus and Settings.
`ScreenService` resolves configured outputs in logical per-screen coordinates.
`Dock` manages placement, edge input and hide transitions. Intelligent mode alone
enables a shared 500 ms native geometry refresh; there is no subprocess polling.
`DockItem` handles pointer interactions, neighbour magnification and indicators.
`DockContextMenu` and `WindowChooser` use the shared glass menu presentation.
Config schema 3 adds defaults without replacing saved pins, module arrays or
unknown keys. Invalid object/array types are rejected instead of reset silently.
QtTest is loaded only with `GLASSMXRPH_DOCK_TESTING=1`. The disposable fixture
uses Quickshell's [AppId pragma](https://quickshell.org/docs/v0.3.0/guide/advanced/)
and [FloatingWindow API](https://quickshell.org/docs/v0.3.1/types/Quickshell/FloatingWindow/).
## Phase 4 launcher
`Launcher` owns only presentation, input and selection. `AppSearch` consumes the
existing shared ApplicationsService; `CommandSearch` consumes CommandRegistry.
Both use pure SearchLogic scoring over pre-normalized catalog fields. Result work
stops while the launcher is closed; no subprocess or duplicate application scan
is introduced. Launches go through ApplicationsService.
`SettingsRegistry` defines canonical page IDs, command aliases, labels and phase
availability. Settings and CommandRegistry share it, so palette destinations are
also reachable normally. Code-owned command extensions may register callbacks;
query text is never shell-evaluated. Future pages are explicitly labelled.
`LauncherState` supplies IPC and owns the window reference. ShellState coordinates
opening/closing and captures ScreenService's active output. ScreenService consumes
native monitor-focus events eagerly; no focus polling is needed. Dock/tray popups
and Settings are dismissed when opening the launcher. Appearance and search
preferences are shared ConfigService/Theme values. Width and delayed height
animations form the opening search pill and respect reduced motion.
## Phase 5 providers
WallpaperService owns discovery, gallery and wallpaper changes. MatugenService observes the selected palette output and serializes generation through ProviderJob, discarding stale results. A short-lived Python helper handles filesystem/provider operations and generated palette files. Settings controls share ConfigService and Theme; Media preferences are ready for the next phase.
## Phase 6 media
`MediaService` is the sole owner of the native MPRIS model, player selection, guarded
actions and a shared 500 ms position sampler. It reads Quickshell's locally extrapolated
position; it does not poll DBus or spawn playerctl. Sampling stops without visible progress
consumers or when paused. `MediaCard` is shared by Settings and
`controlcenter/modules/Media.qml`; Now Playing uses the same service.
`CavaService` runs one optional process for all visualizer consumers. The bundled raw
configuration leaves audio input selection to Cava, emits 24 bars at 30 fps, and never
alters the user's Cava configuration. Its Python launcher execs Cava in place and reports
missing executables. Playback pause, hidden views or disabling Cava stop the process;
failures do not cause restart loops. Song artwork never changes the global accent.
## Phase 7 system controls
`ControlCenter` is an active-monitor overlay with a registry-driven module layout.
`ShellState` coordinates its visibility with existing shell popups. `AudioService`,
`NetworkService` and `BluetoothService` adapt native Quickshell event-driven models.
`SystemService` serializes one-shot JSON provider jobs for visible display/DND/power
controls, polling every five seconds only while needed. `PowerService` owns pending
confirmation; it exposes no direct destructive IPC action. The helper also enforces
confirmation before logout/reboot/shutdown and uses argv arrays with timeouts.
The same modules are reused by detailed Settings pages. Wi-Fi credentials pass to
NetworkManager's native API, not subprocess arguments or shell preferences. BlueZ
pairing uses the existing manager. No pairing daemon is registered.
## Phase 8 telemetry
MetricsService owns a single demand-driven streaming Python collector. MetricsCard, bar MetricsModule and Settings share its snapshot; no UI component polls sensors. The collector owns monotonic CPU/network deltas and rate-limited GPU/storage reads. A bounded CPU history is kept by the service; missing and stale values remain explicit.
## Phase 9 polish
Theme owns contrast selection and reduced-motion intensity. Shared glass components add inexpensive highlights and reversible motion without per-panel blur effects. ScreenService validates captured output references. MetricsService owns bounded restart backoff. The optional compositor example and read-only doctor keep host integration separate from UI state.
## Notifications
`NotificationService` owns the one native `NotificationServer` (org.freedesktop.Notifications),
history (the server's tracked notifications), the banner queue and Do Not Disturb, which is
persisted as `notifications.doNotDisturb`. The server is loaded lazily while enabled. Only one
process can own the bus name: the system helper reports the owner, and while another daemon
(e.g. SwayNC) holds it the shell stays inactive, says so, and the DND tile controls SwayNC instead.
`NotificationPopups` shows banners in a bar drawer like the OSD and yields its spot while the OSD
is up. Banners time out into history, pause while hovered, and are cleared when Control Center
opens. `controlcenter/modules/Notifications.qml` stacks history per app (macOS Notification
Center); `NotificationCard` is shared by both. Critical notifications stay until dismissed and
may break through DND. `tests/notifications_runtime.py` runs on a private session bus.
## Clipboard History
Clipboard History is a launcher mode (`ShellState.launcherMode`), so it shares the launcher's
position, size and keyboard handling; `>clipboard` switches in place without closing the window
and snaps the height instead of animating it. `ClipboardService` reads the user's existing cliphist
history through `helpers/clipboard.py` only when the launcher opens, and keeps the last list cached.
The helper never stores entries (the user's `wl-paste --watch cliphist store` does), decodes
thumbnails for the newest images into the cache, and detaches `wl-copy` when copying.
## Emoji Picker
The Emoji Picker is another launcher mode: `>emoji` switches in place like `>clipboard`, and
`glassmxrph emoji` toggles it directly. Results show as a grid of glyphs with the selected (or
hovered) emoji's name as the section label. `EmojiService` reads `assets/emoji.tsv` the first time
the mode opens; search requires every term and lists name matches before keyword matches. Enter
copies with `wl-copy`. `scripts/emoji-data` regenerates the table from Unicode's `emoji-test.txt`
(skin-tone variants omitted) plus an optional keyword list. `tests/emoji_runtime.py` covers it.