Files
anode/docs/SESSION.md
T

5.2 KiB

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:
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).