docs: document XKB layout indicator, live session replacement, and ANODE DE/WM identity

This commit is contained in:
Luxferre committed 2026-11-26 12:55:11 +02:00
1 parent 158345c168
commit 72b05b650e
5 files changed
+64 -5

No files matched your search

+6
View File
@@ -33,3 +33,9 @@ In `src/dwm/dwm.c`:
1. `anode-session` exports `XDG_CURRENT_DESKTOP=ANODE`, `XDG_SESSION_DESKTOP=anode`, `DESKTOP_SESSION=anode`, and optional `ANODE_SESSION_PROFILE`, seeds `~/.config/anode/autostart` and `~/.config/anode/autostart.d/`, and starts a background waiter polling `_NET_SUPPORTING_WM_CHECK` before invoking `anode-autostart start`.
2. `anode-autostart` evaluates declarative files (`autostart` + optional `autostart.<profile>` + `include` graph via POSIX `awk`), then on `start` evaluates `autostart.d/` drop-ins and `ANODE`-filtered XDG `.desktop` entries with user-over-system basename masking.
3. `src/dwm/dwm.c` triggers `anode-autostart reload` (running only `exec_always`) from interactive `reloadxres` (`Mod4 + Shift + r`, `arg->i = 1`) and post-`SIGHUP` `execvp` restart (`ANODE_DWM_RESTARTED=1`), while `SIGUSR1` and `XA_RESOURCE_MANAGER` pass `NULL` so live theme/DPI reloads never cause autostart loops.
## Live replacement, desktop identity & XKB status
1. **ICCCM `WM_S<screen>` takeover & fallback**: `src/dwm/dwm.c` (`acquirewm`, `--replace`) claims `WM_S<screen>` on `wmcheckwin`, broadcasts `MANAGER`, exits cleanly on `SelectionClear`, and waits up to 5 s for `prev_owner` destruction and `SubstructureRedirectMask`. `scripts/anode-replace` pairs this with a 1.5 s UID-checked `_NET_WM_PID` `SIGTERM` fallback for non-ICCCM WMs.
2. **EWMH/XDG desktop identity**: `dwm` publishes `_NET_WM_NAME = "ANODE WM"`, `XA_WM_NAME = "ANODE WM"`, and `_NET_WM_PID`, while `anode-session` and `anode-replace` clear stale foreign DE variables, export `XDG_CURRENT_DESKTOP=ANODE`, and update DBus/systemd user activation environments so system tools such as `fastfetch` report `Desktop Environment: ANODE` and `Window Manager: ANODE WM (X11)`.
3. **Zero-poll XKB layout indicator**: `src/daemons/anode-statusd.c` selects `XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbNamesNotifyMask` and `XkbGroupStateMask`-filtered `XkbStateNotify` events on the X11 fd, resolving lowercase layout codes via `src/common/anode_xkb_parse.h` (live XKB symbols -> `_XKB_RULES_NAMES` -> group names) to place `<xkb>` directly left of the datetime.
+2 -2
View File
@@ -4,9 +4,9 @@ ANODE supports i3-style session-specific autostart directives paired with per-pr
## Startup lifecycle
- `anode-session` exports `XDG_CURRENT_DESKTOP=ANODE`, `XDG_SESSION_DESKTOP=anode`, `DESKTOP_SESSION=anode`, and `ANODE_SESSION_PROFILE` when `--profile NAME` or `--profile=NAME` is passed.
- `anode-session` scrubs stale third-party DE environment variables, exports `XDG_CURRENT_DESKTOP=ANODE`, `XDG_SESSION_DESKTOP=anode`, `DESKTOP_SESSION=anode`, `XDG_SESSION_TYPE=x11`, and `ANODE_SESSION_PROFILE` when `--profile NAME` or `--profile=NAME` is passed, and supports `--replace` and `--no-autostart`.
- On first session launch, `anode-session` creates `~/.config/anode/autostart.d/` and copies `PREFIX/share/anode/autostart` (falling back to `data/autostart` in source checkouts) to `~/.config/anode/autostart` if absent.
- Once `dwm` advertises `_NET_SUPPORTING_WM_CHECK` on the root window (polled with `xprop` for up to 2 s, falling back to `sleep 1`), `anode-session` launches `anode-autostart start` in the background.
- Unless `--no-autostart` is passed, once `dwm` advertises `_NET_SUPPORTING_WM_CHECK` whose `_NET_WM_NAME` contains `ANODE` (polled with `xprop` for up to 5 s, falling back to `sleep 1`), `anode-session` launches `anode-autostart start` in the background.
- Pressing `Mod4 + Shift + r` (`reloadxres` with `arg->i = 1`) or sending `SIGHUP` to `dwm` (live `execvp` restart carrying `ANODE_DWM_RESTARTED=1`) triggers `anode-autostart reload`, re-running only `exec_always` entries. Background theme/DPI reloads via `SIGUSR1` or `XA_RESOURCE_MANAGER` pass `NULL` and do not re-trigger `anode-autostart reload`.
## Declarative directives
+42
View File
@@ -0,0 +1,42 @@
# ANODE session management & status bar
## Starting or live-replacing an X11 session
- **Fresh X11 startup**: Launch ANODE from `~/.xinitrc` (`exec /usr/local/bin/anode-session [--profile NAME]`) or select the installed `ANODE` session (`PREFIX/share/xsessions/anode.desktop`) in a display manager. `anode-session` also accepts `--replace` and `--no-autostart` and forwards `--replace` to `dwm --replace`.
- **Live replacement (`anode-replace`)**: Replace an active X11 window manager or desktop session without logging out or closing open X11 windows:
```sh
anode-replace --dry-run
anode-replace
anode-replace --profile work --keep-panels
```
| Flag | Behavior |
|---|---|
| `--profile NAME` / `--profile=NAME` | Pass session autostart profile `NAME` (`ANODE_SESSION_PROFILE`) to `anode-session` |
| `--keep-panels` | Keep existing third-party panels, notification daemons, and settings daemons running |
| `--foreground` | Exec `anode-session --replace` in the foreground instead of detaching |
| `--no-autostart` | Skip `anode-autostart start` during replacement |
| `--dry-run` | Print the detected WM (`_NET_SUPPORTING_WM_CHECK` window and PID), cleanup mode, and command without replacing |
| `-h`, `--help` | Print command usage and exit |
- **Two-stage WM handoff**:
1. **ICCCM 2.0 `WM_S<screen>` takeover**: `dwm` claims `WM_S<screen>` on its check window and handles `SelectionClear` by cleanly unwinding (`restart_dwm = 0; running = 0;`). When invoked with `--replace`, `dwm` acquires `WM_S<screen>`, broadcasts a root `MANAGER` `ClientMessage`, and polls `ConnectionNumber(dpy)` for up to 5 s until the previous owner destroys its selection window and releases `SubstructureRedirectMask`.
2. **Non-ICCCM fallback**: Before launching `anode-session --replace`, `anode-replace` records `_NET_WM_PID` from `_NET_SUPPORTING_WM_CHECK`. If the previous window manager still holds `_NET_SUPPORTING_WM_CHECK` after 1.5 s and its PID belongs to the current UID (checked via POSIX `ps`), `anode-replace` sends `SIGTERM` so `dwm --replace` can take over `SubstructureRedirectMask`.
- **Process cleanup & detached readiness**: `anode-replace` terminates duplicate UID-owned ANODE daemons (`anode-statusd`, `anode-powerd`, `anode-touchd`, `anode-vkbd`) and, unless `--keep-panels` is given, stops conflicting third-party panels, notification daemons, and settings daemons (`xfce4-panel`, `mate-panel`, `lxpanel`, `tint2`, `polybar`, `lemonbar`, `fbpanel`, `plank`, `wingpanel`, `dunst`, `xfce4-notifyd`, `xsettingsd`, `xfsettingsd`). By default it launches `anode-session --replace` immune to `SIGHUP` and waits up to 5 s for `ANODE WM` to advertise itself on `_NET_SUPPORTING_WM_CHECK`.
## Desktop environment & window manager identity
- **EWMH & ICCCM properties**: `dwm` sets `_NET_WM_NAME = "ANODE WM"`, `XA_WM_NAME = "ANODE WM"`, `_NET_SUPPORTING_WM_CHECK`, and `_NET_WM_PID` on `wmcheckwin`, and sets `{"anode-wm", "ANODE"}` as the `XClassHint` on status bar windows.
- **Clean session environment**: Both `anode-session` and `anode-replace` unset stale third-party DE variables (`KDE_FULL_SESSION`, `KDE_SESSION_VERSION`, `KDE_SESSION_UID`, `GNOME_DESKTOP_SESSION_ID`, `MATE_DESKTOP_SESSION_ID`, `CINNAMON_VERSION`, `XFCE_SESSION`, `LXQT_SESSION_CONFIG`, `TDE_FULL_SESSION`, `HYPRLAND_INSTANCE_SIGNATURE`, `SWAYSOCK`, `I3SOCK`, `BSPWM_SOCKET`, `WINDOWMAKER`, `E_START`, `GDMSESSION`), export `XDG_CURRENT_DESKTOP=ANODE`, `XDG_SESSION_DESKTOP=anode`, `DESKTOP_SESSION=anode`, and `XDG_SESSION_TYPE=x11`, and sync DBus/systemd user activation environments when available (unless `ANODE_NO_DBUS=1`).
- **System info reporting**: Tools such as `fastfetch` report `Desktop Environment: ANODE` and `Window Manager: ANODE WM (X11)` instead of `dwm`. Terminals that were already open before running `anode-replace` keep their earlier shell environment until a new terminal is launched or `export XDG_CURRENT_DESKTOP=ANODE` is run.
## Status bar & XKB layout indicator
- **Format**: `anode-statusd` publishes `VOL <n%> | <net> | <bat/AC> | <xkb> | YYYY-MM-DD HH:MM` (plus `VOL MUTE` when muted) to the X11 root `WM_NAME`. The `VOL` segment is omitted when no audio backend is detected, and `<xkb>` is omitted cleanly if XKB is unavailable.
- **Text-only layout indicator**: `<xkb>` is a plain lowercase ASCII layout code (for example `us`, `de`, `ru`, `ua`, `latam`, `jp`) positioned immediately to the left of the datetime with no prefix labels, icons, or graphics.
- **Zero-poll event model**: After `XkbQueryExtension()`, `anode-statusd` subscribes to `XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbNamesNotifyMask` (`XkbSelectEvents`) and `XkbStateNotify` filtered solely to `XkbGroupStateMask` (`XkbSelectEventDetails`) so regular keystrokes and modifier presses never wake the `poll()` loop.
- **Layout code resolution (`src/common/anode_xkb_parse.h`)**:
1. Parse the live XKB symbols name (`XkbSymbolsNameMask`), handling `setxkbmap` and `xkbcomp` keymaps while stripping `:N` group selectors, `(variant)` suffixes, vendor prefixes (such as `nec_vndr/jp` -> `jp`), and non-layout components (`pc`, `evdev`, `inet`, `group`, `level3`, etc.).
2. Fall back to the root `_XKB_RULES_NAMES` layouts CSV when the symbols string cannot be matched.
3. Fall back to the first two lowercase ASCII letters of the active XKB group name (`XkbGroupNamesMask`).