# c8-shell

The shell client: Start, All apps, live tiles, charms, flyouts, switcher, splash, notifications; also c8-lock, c8-askpass, c8-polkit and c8-share (the screen-sharing picker).
Depends on: c8ui, c8-protocols, gio, gdk-pixbuf.

Kept apart for their size, beside this file; read the one the work
is in:
- `LIVE-TILES.md`: `live.c`, `templates.c`, providers, `.widget`
  files, pinning over the bus (app and tile writers need it too).
- `PANELS.md`: app charms (`context.c`), status icons and quick
  settings (`status.c`, `quick.c`, `profiles.c`, `network.c`), the
  tray (`tray.c`); most of the shell's side of XR is there.
- `LOCK-AUTH.md`: the programs beside the shell: c8-lock, c8-askpass,
  c8-share, c8-polkit, c8-wallet and its PAM module.

`main.c` (shell-v1 client, windows, appearance), `surface.c` (shell
surfaces: `shell_surface_new/hide/show/set_rect`; a `set_rect` that
changes a shown surface's size suspends its drawing until the
compositor's configure, or a frame of the new content at the old size
shows: XR's charms bar blinked as a card went over it), `start.c` (Start as one
custom widget: header, tiles, app bar, user menu; dragging a tile
reorders it, over a gap between groups (or past either end) it starts a
new group there; right-click/hold on the background → app bar →
Customise shows "Name group" headers, click one (or any group name) to
type it; routes input to
All apps or search while up), `tiles.c` (pinned tiles, groups, `start.ini`,
tile faces; tiles flow in order into 4-cell bands, first fit, only the
order is saved; an old `pos =` only sorts them once; `tiles_drop_index`
finds where a dragged tile lands), `apps.c` (All apps + the Live tiles tab of `.widget` files,
drawn by Start's widget and sliding up from below it; touchpad vertical
scroll drags it with the fingers and springs on SCROLL_STOP; a wheel
scrolls sideways; by touch, Start's widget pans with the finger and
flings (`fling_step` in shell.h), swipe up/down for All apps, tap =
click, swipe a tile down or hold it to select, held then moved drags
it), `search.c` (typing on Start or All apps, or Super+S,
turns Start into results in columns: matching tiles, live ones by their
content too, plus unpinned widgets; apps, PC settings pages and Run; files. Names
match fuzzily (`search_fuzzy`, fzf-like: letters in order, bonuses for
word starts, camelCase and runs); longer text (keywords, comments, live
content) by word starts, ranked below names. Enter
takes the outlined best one; Escape or backspacing to empty goes back),
`files.c` (search's file index: names only, recently-used.xbel plus the
whole home folder breadth-first, skipping hidden, build and Wine
`drive_c` folders, 100k cap; rebuilt on a worker thread when search
opens if over a minute old; kept as two blocks, 16-byte entries and one
text of each folder's path once and the names, a casefolded copy only
after names that fold to something else: ~5 MB for 100k files where an
allocation per path and key was 18; a hit's path is put together for
the search and lasts until the next one), `media.c` (volume via wpctl, brightness via logind
SetBrightness, MPRIS players; the level box is an `osd` role surface,
placed like a panel but not modal), `splash.c` (launch splash, its own SPLASH surface,
ends on the next new window or after 5 s), `panels.c` (charms (in XR a horizontal bar of its own instead, see the compositor's charms bar), clock (its colon blinks with the seconds, redrawn
just after each one turns over: `clock_arm`),
the Start hint (bottom-left hot corner: a picture of Start, or on Start
of the last app, that a click goes to),
Settings flyout (Personalise only on Start; in XR a pivot card, see
`PANELS.md`), switcher: each window a picture of it, asked for
(`window_capture`, main.c) every time the switcher opens and shrunk once
with cairo's filter, over its app's icon (tile, desktop entry, app id)
and title; the pick for a snapped app's other side (`panels_snap`): shell
protocol's `snap` event says which window was snapped where and the
rest of the screen, sent by `c8_shell_snap_changed` at the end of
`c8_views_arrange` only for a fresh snap (a different window snapped,
`shell->snap.view`) with a choice (two or more other apps); side 0
when it's over, or when the same two apps only swapped sides or
moved the split (Super+Left/Right on either of a pair swaps them:
`c8_view_snap` makes the one that was snapped the primary). A third
window mapping beside a pair, or one of the pair closing, sends
nothing: the new or next most recent window takes the rest (an app
whose splash window gives way to its main one used to bring the pick
up twice); the shell fills that rect with the other windows'
pictures, bigger than the switcher's, in a wrapping grid (padded by
`PICK_RIM` so the scroll's clip doesn't cut the outline) that
`pick_fit` sizes for the panel's width whenever it's shown or moves:
as many to a row as fit at `PICK_ITEM_W`, rows evened out (five are
three and two), then widened to fill the row up to `PICK_ITEM_MAX`
(no dead column at the right);
Left/Right/Tab go along the order, Up/Down to the nearest picture in
the row above or below as the grid wrapped (one column when the rest
is a quarter), and Enter or a click activates one, which puts it
there; Escape, a click outside or Start leaves the one already there.
The pick stays until one of those: the compositor sends the
same window again when it moves side or split while the pick is open,
and the panel glides there (`move_tick`, `MOVE_MS` like the
compositor's tween); closing it for any reason sends `pick_done`
(with the window, so one for an older snap is ignored), after which
moves send nothing. While the pick is open the compositor hides the
app that would be behind it, so a pick trailing a split step shows
the desktop past its edge, not that app. Tested headless 2026-12-03: snap, two split steps
and a swap with the pick open, Down in the one-column pick, Escape then
a step (no pick), Enter then a step), `notify.c` (serves
`org.freedesktop.Notifications` and shows toasts in the `[notifications] corner` of config.ini (top-right default; the compositor sends it as the `notification_corner` appearance key, PC settings' General page sets it), one
`osd` surface each: tile colour of the app (`tile_for_app` on the
desktop-entry hint; it matches a tile by id, else one running the app
id's program, else its desktop entry's executable, since
`org.cont8nuum.Files` runs `c8-files`; `app_icon_name` is the tile's
icon, else the entry's, which windows' chrome and the switcher use), slide in, up to 3 stacked with the rest queued (critical ones
have their own 3 and queue, stacked nearest the corner), 7 s
unless critical (black with a red border, never expire, a click doesn't
close them; `notify_ask`'s questions aren't critical but show while
hidden: `notify()`'s `even_hidden`) or the pointer rests on it; click = `default` action
and activates the app's window, drag/swipe towards the edge (finger, or sideways two-finger touchpad scroll) past a third of its width,
or thrown (`FLING_SPEED` px/ms over the last `FLING_STALE` ms before letting go), or the hover close button
dismisses (the touchpad swipe used to strand the toast where it was: the compositor moved the pointer
off it as it slid away; see compositor/CLAUDE.md's shell.c). In a row (XR) a toast can also be dragged or
two-finger swiped down (`sinking`, decided by the way it first goes further), past a third of its height
or thrown, and sinks away from there; short of that it slides back up. A held press's positions come
relative to where the toast was when pressed (c8's implicit grab, touch, the XR ray), so `drag_to`
works from the press alone: it used to add the drag on top, counting earlier movement again
(fixed 2026-12-03). Untested (headless can't hold a button, touch or swipe): drags, the fling, sinking,
 other actions are buttons; in XR (`row()`,
`layout_row`) they sit side by side along the screen's bottom, centred,
critical ones first, rising from below it and sinking away, and
media.c's level box lies flat above them (`notify_row_top`): the
compositor shows that strip at the bottom of the view (its HUD); low battery
(`battery_changed`, from status.c) toasts at 15, 10 and 5 % while
draining, critical, gone on plugging in).

An app's colour: `X-Cont8nuum-Color=#rrggbb` in its desktop entry (a
widget file's `Color=`). Our apps' icons are only the white shape, no
background: the colour is the tile's (`toggle_pin` copies it when
pinned; `tile_color` falls back to it for a tile with no `color =`,
found by the tile's id as a desktop entry or a widget file, so tiles
pinned before need nothing), the square behind the icon in All apps,
the launch splash, and through `app_color` the window's title bar and
toasts of an app with no tile. A new app says its colour there and
ships a white icon. White icons vanish on white: Files' Open with list
and anything else that shows app icons on a light ground hasn't been
looked at. Tested headless: seven of our tiles without `color =` on
Start. Untested: All apps, the splash, chrome and toasts by eye.

Start is one widget but damages per tile: a live update
(`start_tile_changed`) and a flip (`start_tick`, `tick_damages`) draw
only that tile again (`redraw_tile`; all of Start while search or All
apps is up), and `draw_one` skips tiles outside the clip, `start_draw`
the header. A tick draws everything when something moves (scroll, the
opening sweep, a drag, tiles easing to their places) or when it was
asked for through `animate()` (`st.tick_whole`); only `rotate_due`
starts a tick without. A new animation in Start that isn't a tile's
face must go through `animate()` or call `redraw()`. A pressed tile
sinks (c8ui's press tilt, `toolkit/c8ui/WIDGETS.md`): every change of
`tile->pressed` goes through `press_tile` in start.c, which sets the
tile's `tilt` and starts the tick; `start_tick` redraws only that tile
while it moves, and `tile_draw` wraps the face in
`c8ui_tilt_begin/_end`, the darkening kept. Untested by eye: a nested
c8 can't hold a button, and wlrctl's click lets go at once.

Start's background is the picture Photos sets when there is one
(`c8_draw_background`, pattern.c, cover-scaled with gdk-pixbuf; else
the colour and pattern), held still like the pattern. `watch_picture`
(start.c) watches c8-base's `background.h` folder: the Start picture
redraws, the lock one goes to `loginpic.c` (`LOCK-AUTH.md`). Tested
headless: set, removed from PC settings, back to the pattern.

Start hidden for `REST_AFTER_S` (10 s; `rest` in start.c) suspends its
window (no drawing, buffers gone), drops the background picture and All
apps' drawn rows (`apps_rest`) and trims the heap; the tiles' faces stay
so it's back at once. Tested headless: 65 MB to 33 MB behind an app,
Start and search fine after.

Default apps: `defaults.c` lists the kinds PC settings' Default apps
page assigns (Web browser, Mail, Terminal, File manager (`files`,
`inode/directory`), Music, Video, Photos, Calendar, Maps, Text editor). `apps.c` adds each to All apps (ids `default-ROLE`,
the kind's icon, pinnable like any app; the shipped Start has the browser,
the file manager and the terminal), with `exec = @default ROLE` (`@terminal` for the
terminal); a kind whose command a `.widget` also has as `Exec=`
(Calendar) takes that widget's id, provider and size, so pinning from
either tab makes the one live tile, and the widgets are scanned before
the apps for it. `shell_launch` resolves `@default ROLE` when it's used: the
GIO default for the kind's first type, run as All apps would run its
desktop entry (`apps_command`); none set opens `c8-settings --page
defaults`. An app entry counts as pinned by a tile with its id or one
running the same command (`tile_find_exec`).

Shared bits: `shell.h` has the small helpers every file uses (`now_ms`,
`ease_out`, `in_rect`, `set_str`, `metro_palette`, `left_click`, and for
Start, All apps and search alike `scroll_step`/`scroll_by`/`scroll_clamp`/
`scroll_reveal`, `arrow_dir`, `focus_distance`); `pixels.h` (c8-shell,
c8-lock and c8-askpass) turns a pixbuf into a cairo image
(`image_from_pixbuf`) and reads the account's name and picture
(`account_read`).

`wake.c` serves `org.cont8nuum.Wake1` (c8-protocols has the
contract) as `org.cont8nuum.Wake`, the newest shell winning like
Tiles: the list in `$XDG_STATE_HOME/cont8nuum/wakes.ini` (a group a
wake, `APP TAG`; when, every, command), read again when the name is
won. Only the name's owner runs wakes, or a nested shell on the same
bus would run each twice. One GLib timer to the next due one, never
longer than `LOOK_EVERY` (60 s): the main loop's clock stops in a
suspend and the wall clock doesn't. A due wake runs through
`c8_shell_v1_launch` (the session's environment, no splash) with
`--c8-wake TAG DUE` added; a one-off leaves the list first, a repeating
one moves to the first time after now on its grid (missed runs are
one). Toasts from a woken app open it when clicked because notify.c
launches the `desktop-entry` of a toast with no default action. Tested
headless with a test app on the nested bus: a wake for an app not
running (started, ran, quit), one booked from a wake, one handed to
the running copy, a repeat that had missed two, the 30 s limit, Cancel,
List and the refusals; Clock's timer as a toast with its window
closed, and the toast's click opening Clock. Untested: across a suspend, a shell restart with wakes
booked, the real session.

`logind.c` in the shell locks on logind's Lock signal and before sleep
(holding a delay inhibitor until locked).
`drives.c`: a toast when a drive is plugged in (GVolumeMonitor's
`volume-added`, so gvfs; removable or ejectable ones that
`should_automount`, never what was there at login): its name, Open /
Not now through `notify_ask`. Open mounts it if need be and runs
`xdg-open` on its root; nothing is mounted before. Untested: all of it
with a real drive (none was plugged in).

Stealth mode (c8-base's `stealth.h`): Start's name is the persona's and
its picture the letter tile (`user_name`, `start.c`); `account_read_for`
(`pixels.h`) gives our own account the persona's name and no face, the
login staying real for PAM; Wi-Fi names in the status icon and the
Networks flyout are `C8_STEALTH_WIFI`; search's file names and folders,
toasts (summary and body at receipt, so a flip doesn't change one up),
tray titles and the drive toast go through `c8_stealth_show`. main.c's
watch redraws Start and the status. c8-lock, c8-askpass and c8-polkit:
`LOCK-AUTH.md`. Tested headless: Start, and a live flip both ways.
