Shell Lua API

shady-shell draws whatever its Lua config describes. The default desktop is itself a config, rices/tide/shell.lua, and so is the shell’s own default.lua, Meridian. Read either alongside this page.

Config file

The shell loads the first of:

  1. $SHADY_SHELL_CONFIG
  2. $XDG_CONFIG_HOME/shady/shell.lua (or ~/.config/shady/shell.lua)
  3. the shell.lua of the rice in $SHADY_RICE, Tide when it is unset. A rice is a directory named after it in $SHADY_RICE_PATH (colon-separated), $XDG_DATA_HOME/shady/rices, $SHADY_ROOT/rices or $XDG_DATA_DIRS/shady/rices, looked for in that order, the same places Shady looks for the rice’s config.lua and init.lua. Each file is found on its own, so a rice can come in parts: Shady installs Tide’s compositor side and Gloam its shell.lua.
  4. default.lua from the data directory ($SHADY_SHELL_DATA_DIR overrides it), also for SHADY_RICE=none

If your config fails to load at startup, the shell logs the error and falls back to default.lua, unless SHADY_SHELL_NO_FALLBACK=1 makes it exit instead (the greeter does). Edits are picked up live: saving any .lua file in the config’s directory reloads the config in a fresh Lua state. If the new version fails, the error is logged and the running UI stays as it was. require finds modules next to the config and in the data directory.

To keep Tide and change a few things, start your config from it; Customizing lists the options and what it returns:

local tide = shell.base("tide", { palette = { accent = "#FF9E64" } })

shell.base(rice[, options]) runs that rice’s shell.lua in your config, with options as its argument, and returns what the rice returns. To build on the plain UI instead, dofile(shell.data_dir .. "/default.lua").

Views

Every surface has a view function that returns a widget tree. The shell calls it whenever the surface is repainted: when the compositor’s state changes, a polled value changes, the clock ticks, the pointer moves onto something with an id, or you call shell.redraw(). Views should only read state and build widgets; they may not open or close popups.

The first argument is a context table:

FieldMeaning
namethe bar or popup name
outputoutput name ("DP-1"), if the surface is on a known output
width, heightsurface size in logical pixels
scalebuffer scale
hoveredid of the widget under the pointer, if any

Popups receive the table passed to shell.open as a second argument.

shell.bar{...}

A bar on every output, or on the outputs listed.

shell.bar {
    name = "top",                 -- required, unique
    edge = "top",                 -- "top" or "bottom"
    size = 38,                    -- height in logical pixels
    exclusive = true,             -- reserve space so windows avoid it
    layer = "top",                -- background | bottom | top | overlay
    outputs = { "DP-1" },         -- default: all outputs
    view = function(ctx) return shell.row { ... } end,
}

shell.popup{...}

A surface that is opened and closed on demand.

shell.popup {
    name = "quick",
    anchor = { "top", "right" },  -- edges; none centres it
    margin = { top = 42, right = 8 },
    width = 250,                  -- omit width/height to fit the content
    keyboard = "none",            -- none | exclusive | on_demand
    close_on_blur = false,        -- close when it loses the keyboard
    persistent = false,           -- keep it open, like a bar
    outputs = nil,                -- "all": persistent on every output, one each
    fill = false,                 -- cover the whole output (anchors and size ignored)
    exclusive = 0,                -- pixels to reserve along its anchored edge
    input = "all",                -- or "widgets": take the pointer only over interactive widgets
    text_input = false,           -- take text from input methods (Hangul, Japanese, ...)
    layer = "overlay",
    view = function(ctx, args) ... end,
    on_key = function(key, text, args) ... end,
}

With close_on_blur = true the popup closes when focus leaves it: the keyboard moving elsewhere (with a keyboard mode that takes it), another window taking the focus, or a click anywhere else but on a bar or a dock. While such a popup is open the shell lays an invisible surface over the windows (on the top layer, kept off the zones bars and docks reserve) and lets its desktop surfaces take the whole pointer, so a click on any window, the focused one included, or on the desktop reaches the shell and closes the popup instead. Clicks on a bar or a dock still go to them: a bar’s button often toggles the popup itself.

With text_input = true (and a keyboard mode) the popup takes text from the input method, through text-input-v3: what is still being composed is ctx.preedit in the view, and committed text arrives in on_key with an empty key name, like typed text. Mark the widget where text goes with caret = true, so the input method places its candidate window next to it.

Without width or height the popup takes its content’s natural size and follows it as the content changes, except along an axis it is anchored to at both ends (anchor = { "top", "bottom", "right" } without height): there the compositor stretches it between the two edges, like a side panel running the full height of the output. on_key receives the xkb key name ("Escape", "Return", "Up", "BackSpace", "a") and the text it types ("" for none).

A fill popup covers its output: a full-screen launcher, or with layer = "background" a wallpaper. Its view gets the output’s size as ctx.width and ctx.height. Background and bottom layer surfaces are drawn behind the windows, also in spatial mode, and only take the pointer where no window is.

With input = "widgets" the surface takes the pointer only over widgets that react to it (on_click, on_drag, on_scroll, id or hover); everywhere else clicks fall through to the windows or the desktop below. This makes a full-screen fill layer usable as a desktop with a few clickable things on it.

A persistent popup is opened by the shell itself as soon as an output is ready, stays on one output, and moves to another when its output goes away (a monitor unplugged, a VT switch). The greeter’s login card is one (GREETER.md).

With outputs = "all" a popup is persistent on every output instead: one copy per output, following hotplug, each getting its own output as ctx.output. Wallpapers, docks and desktop widgets use it. shell.open, shell.close and shell.is_open are meant for popups that come and go, not for these.

Opening popups

Function
shell.open(name[, args])Open (or reopen) a popup. args.output (an output name) and args.margin override its placement; the whole table is passed to its view.
shell.close(name)Close it. A popup with exit styles plays them first; meanwhile it ignores input and no longer counts as open, so it can be reopened at once.
shell.toggle(name[, args])Open or close it.
shell.is_open(name)Whether it is open.
shell.redraw()Repaint every surface, e.g. after changing your own state.

Widgets

Widgets are tables; these constructors fill in type:

Constructor
shell.row{...} / shell.column{...} / shell.box{...}Container; its array part holds children. box is a row unless direction = "column".
shell.stack{...}Container whose children all lie over the same area (see Layout).
shell.icon(name, {size=, stroke=, color=})A built-in line icon: wifi, volume, mute, bluetooth, moon, sun, capture, play, pause, next, previous, battery, search, power, grid, plus, close, sliders, lock, music, check, bell. size defaults to 16, stroke to 2 (in a 24-unit box).
shell.text(text, {...})A line of text.
shell.pip{radius=, lit=}The focus dot: a glowing dot when lit, a faint ring otherwise.
shell.image{path=, width=, height=, fit=}A picture: PNG, and JPEG and WebP when the shell is built with libjpeg and libwebp (shell.image_formats lists them). fit is "fill" (stretched to the box, the default), "cover", "contain", "center" or "tile". A file replaced on disk is read again.
shell.canvas{...}Vector shapes drawn in the widget’s own coordinates: lines, rectangles, circles, arcs and paths (see Canvas).
shell.spacer{...}An empty box that grows (or has a fixed width/height).

Children may contain false (skipped, so cond and widget or false works) and plain lists of widgets (spliced in, so loops can build them).

Layout

Containers lay children out along one axis, like a simplified flexbox.

PropertyDefault
direction"row""row" or "column"
gap0space between children
padding0number, {vertical, horizontal} or {top, right, bottom, left}
align"center"cross axis: start, center, end, stretch
justify"start"main axis: start, center, end, space-between
width, heightnaturalfixed size
min_width, max_width, min_height, max_heightlimits on the natural size
grow0share of spare space along the parent’s main axis
shrink1 for text, 0 otherwiseshare of a deficit; text then ellipsizes
clipfalsehide children that do not fit (e.g. a task list)

In a stack (direction = "stack") every child gets the whole inner area to itself. A child with left, top, right or bottom is pinned that far from the edge (both of a pair: stretched between them, e.g. a full-size backdrop with all four 0); otherwise justify places it horizontally and align vertically. Later children are drawn over earlier ones.

Style

Property
backgroundcolour or shell.gradient(direction, c1, c2[, c3, c4]), direction "vertical", "horizontal", "diagonal" or "radial" (from the centre of the box out to its edges)
border, border_widthhairline outline (width 1 by default)
radiuscorner radius
colortext colour (text and pip)
opacity0..1 for the widget and its children
scaledrawing scale about the widget’s centre, default 1
rotatedrawing rotation about the widget’s centre, in degrees clockwise
skewhorizontal shear about the widget’s centre, in degrees (-75..75): positive leans the top to the right, like italics, and turns a box into a parallelogram. Children are sheared with it; give them the opposite skew to stand upright again
translate{x, y} drawing offset in pixels
shadow{x, y, colour[, blur]}: a copy of the widget’s shape, offset behind it: hard, or soft over blur pixels (up to 96). With no offset a blurred shadow is a glow. false for none
hovera table of style properties used while the pointer is over the widget
pressa table of style properties used while the left button holds the widget down (over hover); with a spring, a key that sinks and springs back: press = {translate = {0, 3}, shadow = {0, 1, ink}}
fontPango font, e.g. "Sans SemiBold 9.5"; default "Sans Medium 9.5"
letter_spacingpoints, default 0.25
text_align0 left .. 1 right, within the text’s box
ellipsizedefault true
wrap, max_linesbreak text into lines at max_width (or width), ellipsizing after max_lines if set
outlinetext: {width, colour}, a stroke around the glyphs under their fill, for sticker lettering
text_shadowtext: {x, y, colour}, a hard copy of the (outlined) glyphs offset behind them. Unlike shadow, it follows the letters, not the box. Both make the text’s box larger by what they add

Colours are "#RGB", "#RRGGBB", "#RRGGBBAA" or {r, g, b, a} in 0..1.

scale, rotate, skew and translate move only what is drawn; layout and hit-testing use the untransformed box.

Animation

Views return a new tree on every repaint; an animated widget is matched with its previous self and springs from its old look to its new one. Position and size (relative to the parent, so children ride along with a moving parent), background (gradients included), border, color, opacity, scale, rotate, skew, translate and shadow (its blur too) all animate.

Property
animatetrue, a preset ("smooth", "snappy", "bouncy", "gentle"; "pop", which jumps past its target and settles, for things popping in; "jelly", which wobbles a few times; "clack", a quick key going down and back) or {stiffness = n, damping = n}; false turns it off
enterstyle a new widget starts from, e.g. {opacity = 0, scale = 0.96, translate = {0, -6}}
exitstyle a closing popup’s widgets go to before the popup goes away
keyidentity for matching; by default the id, else the parent’s key and the child’s position

enter, exit, hover and press animate with "smooth" without animate. key is for widgets that need a stable identity but must not become ctx.hovered targets, such as a dot that comes and goes inside a pill.

shell.row {
    id = "clock", animate = "snappy",
    background = open and t.accent_deep or a(WHITE, 0.03),  -- fades
    enter = { opacity = 0, translate = { 0, -8 } },          -- slides in
}

While springs move, the shell repaints on every frame from the last tree without running the view; when they settle it goes back to repainting only on changes.

A shadow is drawn outside the widget, and a surface shows nothing past its own edge: give a popup’s card padding around it for its shadow to fall in, and input = "widgets" so that the empty margin does not take clicks (the default UI’s panel does both).

Canvas

shell.canvas draws vector shapes, for what boxes and text cannot say: a dial, a gauge, a graph, a mark. Its array part lists the shapes, drawn in order, in logical pixels from the widget’s top left corner:

shell.canvas {
    width = 64, height = 64,
    { "circle", 32, 32, 28, stroke = "#ffffff30", width = 4 },
    { "arc", 32, 32, 28, 0, 3.6 * percent, stroke = t.accent, width = 4, cap = "round" },
    { "line", 32, 32, 32, 12, stroke = t.text, width = 2, cap = "round" },
    { "path", "M 8 56 Q 32 40 56 56", stroke = t.text_dim },
}
Shape
{"line", x1, y1, x2, y2}a straight line
{"rect", x, y, width, height, radius = n}a rectangle, with rounded corners if radius is set
{"circle", cx, cy, r}a circle
{"arc", cx, cy, r, from, to}part of a circle, in degrees clockwise from 12 o’clock; filled, it is closed along its chord
{"path", "M 0 8 L 4 0 C ... Z"}an SVG-style path: M, L, H, V, C, Q and Z, and their relative lower-case forms
Shape property
fill, strokea colour or a shell.gradient (spanning the shape’s own extent), or true for the widget’s color, which follows hover and animation. A shape with neither is stroked in the widget’s colour
widthstroke width, default 1
cap"round" for round ends and joins
dash{on, off} lengths, or one number for both
opacity0..1 for this shape

With view = {width, height} the shapes are drawn in a box of that size, scaled to the widget, so one drawing fits any size (an icon in a 24-unit box, like the built-in ones). A canvas takes its size from width and height or from its container (pinned in a stack, for instance); what falls outside it is not drawn. false among the shapes is skipped and a list of shapes is spliced in, as with children.

A canvas is part of the widget tree like any other widget: it is repainted only when its shapes change, costs nothing while idle, and takes opacity, scale, translate, rotate, shadow, hover and animate as a whole. The default UI draws its day line, the sun on it and the day wave of its clock sheet with canvases; examples/sysinfo.lua draws a load dial.

Interaction

Property
idnames the widget; ctx.hovered reports it when the pointer is over it
on_clickfunction(button, info) with button = "left", "right" or "middle"
on_dragfunction(info): called when the left button goes down on the widget, on every move while it is held (also outside the widget, within the surface) and once more with info.done = true on release, or when the pointer leaves the surface
on_scrollfunction(dy, dx, info): wheel or touchpad scrolling over the widget, in pixels, positive down and right

info holds the widget’s box (x, y, width, height), the pointer inside it (px, py), the same as 0..1 fractions of its size (fx, fy, clamped) and the output. The deepest widget with the handler under the pointer gets the event, the one drawn last if they overlap; on a widget with both, a left press goes to on_drag before on_click.

shell.stack {
    width = 200, height = 24,
    on_drag = function(info) set_volume(info.fx * 100) end,
    on_scroll = function(dy) set_volume(volume - dy / 2) end,
    ...
}

Windows and applications

shell.window declares an ordinary application window instead of a layer surface. It is opened and closed like a popup, the compositor decides its size (ctx.width, ctx.height), and it takes view, on_key and text_input:

shell.window {
    name = "main", title = "Notes", app_id = "my-notes",
    width = 800, height = 600,
    view = function(ctx)
        return shell.box { width = ctx.width, height = ctx.height, background = "#11111B" }
    end,
}
shell.after(0, function() shell.open("main") end)

shady-shell --app file.lua runs such a file as an application of its own: its own process, no fallback config, no reloading, and it ends with its last window. shell.quit() then ends the application, not the session.

shell.reload()run the config again, once the current callback has returned
shell.compositor_lua(code)run Lua in the compositor (as shadyctl lua); false when there is no connection

Compositor state and actions

State comes from the compositor over the shady-shell-v1 protocol.

FunctionReturns
shell.workspaces(){"main", "x", ...}
shell.active_workspace()name
shell.windows()list of {id, app_id, title, workspace, focused, maximized, fullscreen}
shell.focused()the focused window or nil
Action
shell.workspace(name)switch workspace
shell.focus(id)focus a window (switching to its workspace)
shell.maximize(id) / shell.fullscreen(id)toggle
shell.move(id, workspace)move a window
shell.close_window(id)ask a window to close
shell.cycle()focus the next window
shell.quit()end the Shady session

Window arguments may also be the window tables themselves.

Other data

Function
shell.date(format)strftime of the local time; views using it repaint each minute, or each second if the format shows seconds
shell.poll(command, ms[, fallback])the trimmed output of sh -c command, rerun every ms (at least 100); fallback or "" until the first run ends
shell.listen(command[, fallback])the latest line printed by a long-running command, restarted if it exits
shell.apps(query, limit).desktop applications matching the query: {name, exec, categories, icon}, categories being the entry’s Categories= as written ("Network;WebBrowser;", or ""), icon the PNG its Icon= names in the hicolor theme or pixmaps of the XDG data directories (absent when there is none; SVG-only icons are not found)
shell.launch(app) / shell.spawn(command)run an app or a command
shell.themethe palette: accent, accent_2, accent_deep, surface, text, text_dim, danger (from the SHADY_SHELL_* variables)
shell.mix(a, b, t)blend two colours
shell.alpha(colour, a)multiply a colour’s alpha
shell.log(...)write to the shell’s log
shell.after(ms, fn)run fn once after ms milliseconds; returns an id for shell.cancel(id)
shell.key(keys)press a compositor shortcut such as "Super+t" (the IPC key command); false when not connected
shell.shortcuts()the compositor’s shortcut list as of its last shortcuts event: {keys, group, description} each (see Shortcut overlay)
shell.toggle_shortcuts()ask the compositor to toggle the shortcut overlay; false when not connected
shell.screenshot([delay_ms]), shell.screenshot{delay=, path=, output=, window=}ask the compositor to save its next frame, after the delay, to ~/Pictures or path (the IPC screenshot command; needs no grim), only output, or only the window with that id; the value event with screenshot.saved (the path) follows once it is written. Give a closing panel ~300 ms to leave the picture
shell.image_crop(src, dst, x, y, width, height)save part of a picture, in its own pixels, as a PNG; true, or nil and a message
shell.clipboard()what is on the clipboard: the text and "text", or a picture’s path and "image", or nothing (see Clipboard)
shell.set_clipboard(text), shell.set_clipboard{path=}serve text, or a PNG/JPEG/WebP picture, as the clipboard until something else is copied; true when served
shell.clipboard_available()whether the compositor gives the shell the clipboard (wlr-data-control)
shell.notify(summary[, body[, app]])show a notification of the shell’s own, like one a client sent
shell.fonts(dir)make the font files in dir (relative to the config file, or absolute) available by family name; call it before the views use them. The data directory’s fonts holds Manrope and Instrument Serif, which the default UI is set in: shell.fonts(shell.data_dir .. "/fonts")
shell.data_dir, shell.config_pathwhere the default UI and your config live
shell.files(dir)the directory’s entries sorted by name, hidden ones left out: {name, path, dir, mtime, size} each; nil, message when it cannot be read
shell.stat(path){dir, mtime, size} of a file or directory (following links), or nil
shell.watch(path, fn)call fn once changes settle, whenever a file in the directory path (or the file path, which may not exist yet) is written, added, removed or renamed; returns an id for shell.unwatch(id), or nil, message
shell.image_size(path)a picture’s width and height, or nil, message; it decodes the file (for shell.image to reuse)
shell.image_formatsthe picture formats this shell reads, {"png", "jpeg", "webp"}
shell.renderer"gl", or "shm", which draws no shader effects

shell.poll and shell.listen start their command the first time a view asks for it and keep it running for as long as the config is loaded. Any change in their value repaints the views. Together with shadyctl subscribe (see IPC_API.md) they cover most status widgets without native code:

local volume = shell.poll("wpctl get-volume @DEFAULT_AUDIO_SINK@", 2000)
local battery = shell.poll("cat /sys/class/power_supply/BAT0/capacity", 30000)

Notifications

The shell can be the desktop’s notification server (org.freedesktop.Notifications, spec 1.2, over sd-bus). A config asks for it; it keeps running across reloads. If another daemon owns the name, it returns false and the shell leaves that daemon alone.

Function
shell.notification_server{timeout = ms}serve notifications; timeout (default 5000) applies when a client asks for the server’s default. Critical ones without a timeout stay until dismissed.
shell.notifications()the history, newest first (at most 50): {id, app, summary, body, icon, urgency, time, active, actions}, urgency being "low", "normal" or "critical", time seconds since the epoch, actions a list of {key, label}
shell.dismiss_notification(id)close it as dismissed by the user
shell.invoke_notification(id, key)tell its client the action was chosen, then dismiss it; by convention "default" is a click on the notification itself
shell.clear_notifications()forget the history, closing the active ones

Every change (one arrives, expires, closes or is replaced) emits the notifications event and repaints the views. Active notifications are the ones to show as toasts; the default UI opens a toasts popup while there are any:

shell.notification_server()
shell.on("notifications", function()
    local any = false
    for _, n in ipairs(shell.notifications()) do any = any or n.active end
    if any ~= shell.is_open("toasts") then
        if any then shell.open("toasts") else shell.close("toasts") end
    end
end)

Clipboard

Through wlr-data-control the shell is a clipboard client of its own: it serves what it copies (shell.set_clipboard, no wl-copy process) and reads what any other client copies. Each copy it reads becomes the clipboard event with ("text", text) or ("image", path); pictures (PNG) are written to $XDG_CACHE_HOME/shady/clipboard/. A copy that a password manager marks as secret (x-kde-passwordManagerHint) is never read, and texts over 1 MiB or pictures over 16 MiB are skipped. SHADY_SHELL_NO_CLIPBOARD=1 turns it off. What the shell copies stays on the clipboard until something else is copied or the shell exits.

shell.on("clipboard", function(kind, value) shell.log("copied " .. kind) end)
shell.set_clipboard("hello")
shell.set_clipboard({ path = "/tmp/shot.png" })

The data directory’s clipboard module keeps a history of these copies and has a panel to copy from it again (see Parts with a look).

Wallpaper

The data directory’s wallpaper.lua gives a config a wallpaper that people can change without editing it. A rice says what its own wallpaper is; dropping a picture in ~/.config/shady, or choosing one with shady-wallpaper, replaces it:

local wallpaper = require("wallpaper")
wallpaper.install {
    default = { shader = shell.shader("shaders/sea.frag"), uniforms = { accent = P.accent } },
}

Each output shows the first of these that can be drawn:

  1. a choice made while running: wallpaper.set(source[, output]), or shady-wallpaper set PATH [OUTPUT]; kept in $XDG_STATE_HOME/shady/wallpaper, so it lasts across sessions
  2. the config’s outputs[output], then its source
  3. a picture in $XDG_CONFIG_HOME/shady: wallpaper-<output>.<ext>, then wallpaper.<ext> (png, jpg, webp), then the folder wallpapers/
  4. the rice’s default
  5. color, or nothing, and the compositor’s background shows

A source that cannot be drawn, such as a missing file or a folder without pictures, is logged once and skipped. Files are watched: a picture saved, replaced or removed shows at once, with a cross-fade.

A source is any of:

Source
"~/Pictures/sea.jpg"a picture; relative paths are relative to the config
"~/Pictures/walls"a folder: a slideshow, a picture every interval seconds
"#1E1E2E", shell.gradient(...)a colour
{ path = ..., fit = "contain" }, { dir = ..., interval = 60, order = "random" }the same with their own options
shell.shader(...), { shader = ..., uniforms = {...} or function(ctx), color = ... }a full-screen shader, given what is drawn over it as u_tex (a lock screen’s clock, from wallpaper.widget); color is what the wl_shm renderer shows instead
function(ctx) return widget end, { view = fn }anything a view can draw: canvases, images, text
{ plugin = "name", options = {...}, widget = "name.type", props = {...} }a native plugin’s widget, loaded on first use
OptionDefault
defaultthe rice’s own wallpaper
sourcethe config’s choice, which beats a dropped picture
outputs{}sources by output name
fit"cover"how pictures fill the output (see shell.image)
colordrawn under everything, and in the bars contain leaves
interval600seconds per picture in a folder; 0 to stay on one
order"name"or "random"
transitiontruethe cross-fade: false, or a spring {stiffness, damping}
drop_intruelook for pictures in ~/.config/shady
remembertruehonour set and the state file
name"wallpaper"the layer’s namespace, for shady.layer_effect (first call only)

install declares one background layer on every output the first time it is called; later calls change only the options they pass, so a config built on a rice with shell.base can call it again with its own source. The module also has:

Function
wallpaper.widget(ctx[, output])the output’s wallpaper as a widget the size of ctx, e.g. under a lock screen’s clock
wallpaper.set(source[, output]), wallpaper.clear([output])choose (paths and colours are remembered), or go back to the config’s
wallpaper.next([output]), wallpaper.previous([output])move a slideshow on or back
wallpaper.current([output]){kind, path, fit, folder, origin}: kind is picture, shader, view, widget, color or none; origin is set, config, file, rice or none
wallpaper.is_picture(name)whether a file name has an extension this shell reads

From a terminal, or a compositor key binding:

shady-wallpaper set ~/Pictures/sea.jpg        # every output
shady-wallpaper set ~/Pictures/walls DP-1     # a slideshow on one
shady-wallpaper next
shady-wallpaper clear

Lock screen

A popup with lock = true is a lock screen: while the session is locked (ext-session-lock-v1) one copy covers every output, above everything, with the keyboard. Its anchors, layer and size are ignored.

Function
shell.lock()lock the session and show the lock popups; false when the compositor has no session lock
shell.unlock()unlock and close them
shell.locked()whether this shell holds the lock
shell.can_authenticate()whether the shady-auth helper is installed (it is not built without libpam); check it before shell.lock(), or nothing will unlock
shell.authenticate(password, fn[, options])check the password of the user running the shell with PAM, in the shady-auth helper; calls fn(ok, reason) once. password nil answers no password, for a fingerprint-only service. Options: service (default: the first of shady-lock, swaylock, login in /etc/pam.d), on_message = function(kind, text) for what PAM says on the way (“Place your finger…”). Returns an id for shell.cancel_authentication(id); raises an error when the helper cannot start or the password is over 1022 bytes

If the compositor ends the lock itself, the unlocked event follows. When a locking shell dies the session stays locked, and the compositor publishes session.lock = "abandoned"; a shell started then can lock again and take over (Tide’s does).

shell.popup {
    name = "lock", lock = true, keyboard = "exclusive",
    view = function(ctx) return shell.text(shell.date("%H:%M")) end,
    on_key = function(key, text)
        if key == "Return" then
            shell.authenticate(typed, function(ok) if ok then shell.unlock() end end)
        end
    end,
}

Events

shell.on(name, fn) registers a handler:

EventWhen
"launcher"the compositor asked for the launcher (shady.toggle_launcher()), or the shell started with SHADY_SHELL_OPEN_LAUNCHER=1
"change"the compositor’s workspaces or windows changed
"notifications"a notification arrived, expired, closed or was replaced (see Notifications)
"shortcuts"the compositor asked for the shortcut overlay (Super+Shift+/) and sent its list
"value"a published compositor value changed; the handler gets (key, value), value nil when removed. Values already set are replayed when the shell connects
"unlocked"the compositor ended the session lock this shell held

Shortcut overlay

On Super+Shift+/ the compositor sends every shortcut of the session (its own, the rice’s described shady.binds, each plugin’s) and the shell emits shortcuts. The data directory has a ready overlay that handles it:

require("shortcut_overlay").install()            -- the default look
require("shortcut_overlay").install {
    name = "my-shortcuts",                       -- popup name, for shady.layer_effect
    palette = shell.theme,                       -- text, text_dim, accent, surface; read per repaint
    font = "Sans 9.5", bold = "Sans SemiBold 9.5", title_font = "Sans SemiBold 13",
    cap = function(p) return { radius = 6, background = p.surface } end, -- key cap style
    frame = function(body) return shell.column { padding = 24, body } end, -- the card
    columns = 2,                                 -- fewest columns; more if it does not fit
    order = { "Shady", "Desktop" },              -- groups shown first
}

It covers the output, dims what is behind, flows the groups into columns that fit the screen and closes on Escape, Enter or a click. The default UI, Horizon and Objects each install it with their own look (shell/shortcut_overlay.lua). A config can also draw its own from shell.shortcuts().

Modules without a look

Besides wallpaper and shortcut_overlay, the data directory has modules that do the work behind a desktop’s parts and leave the drawing to the rice. Meridian (default.lua) and Tide are both built on them; each file documents its functions at the top.

Module
require("machine")the machine’s state, read in views with shell.poll: volume(), mic_muted(), brightness(), battery(), battery_time(), wifi(), bluetooth(), profile(), media(), cpu(), memory(), disk(), uptime(); and machine.act to drive it: volume(v), mute(), brightness(v), wifi(), bluetooth(), profile(), media(what), suspend(), reboot(), poweroff(). A missing tool reads as nil. A value the shell just set wins over the poll for a few seconds. has(command), have.<tool>
require("lockscreen").install{view=, ...}the lock screen’s typing, the PAM check, a fingerprint reader listening alongside, and taking an abandoned lock over; view(ctx, state) draws it from state.length, busy, message, error, attempts. Returns lock() and available(); before_lock and fallback hook in
require("toasts")which notifications to show (shown(limit)), do-not-disturb kept across restarts and shared by rices (dnd(), set_dnd(on)), what a click does (activate(n)), today(), and follow{popup=, hold=} to keep a popup open exactly while there is something to show
require("commands").listen(key, handlers)words published by the compositor (shady.publish(key, "lock " .. serial)) back into calls, ignoring the value replayed when the shell connects
require("launches")which applications are launched, how often and how lately, kept across restarts: launch(app) (record and run), record(app), score(app), sort(apps) (most used first), top(apps, n)
require("focus_timer")a span of time from now, kept across restarts, with a notification at its end: start(minutes), stop(), running(), left(), span()
require("almanac")dates and the sky: month(year, month) as weeks, shift, month_name, moon_phase, moon_lit, moon_name, moon_path (for shell.canvas), year_day, week
require("statefile")(name)a few key=values that outlive the shell, in $XDG_STATE_HOME/shady/<name>: get(key), set(key, value) (the file is replaced at once), reload(), watch(fn): fn() after another process changed it

Parts with a look

These come with a default look that follows shell.theme, and take a palette, fonts and drawing functions so a rice can make them its own. Each file documents its options at the top.

Module
require("clipboard")the clipboard’s history, kept across restarts (history(), copy(text or {path=} or entry), pin(id), remove(id), clear()), and install{...} a panel: search, Enter copies, Tab pins, Delete removes; toggle() opens it. The Settings app sets how much is kept
require("dock")a dock of pinned applications, in your order, then what has a window: click focuses or starts, drag moves a pin, right click for Pin/Unpin, New window, Close, Move. Pins in the statefile dock (pins(), pin(name), unpin(name), move(name, by)), which the Settings app also edits. install{art=, launcher=, style={shelf=, tile=, mark=, menu=}}
require("screenshot")screenshots without grim or wl-copy: install{...}, open([mode]) for a picker (region, window, screen), take{mode=} at once. Saved to ~/Pictures/Screenshots, copied to the clipboard, announced with a notification

The Settings app

shady-settings [page] (shady-shell --app apps/settings.lua; from a rice, require("settings_app").open([page]), which finds the launcher of the shady-shell that is running) sets the accent, the wallpaper (from thumbnails of ~/Pictures, ~/Pictures/Wallpapers and ~/.config/shady/wallpapers), window corners and gaps, the keyboard and touchpad, the dock’s pins, how much clipboard history is kept, and quiet hours. It writes where the running desktop already looks: ~/.config/shady/settings.lua (read by Tide’s config, and applied at once with shady.set; the compositor value shady.settings changes for shells that redraw), the wallpaper state that shady-wallpaper writes, and the statefiles dock, clipboard and notifications, which those modules watch.

With SHADY_SHELL_OFFLINE=1 (the headless tests) machine reads nothing and runs nothing: every source is nil and every action only logs.

Shader effects

With the GL renderer (the default), any bar, popup or widget can be drawn through a GLSL ES 1.0 fragment shader. Effects are skipped, with one log line, on the wl_shm renderer.

shell.bar {
    name = "top",
    shader = shell.shader("shaders/aurora.frag"),
    uniforms = { strength = 0.55, accent = shell.theme.accent },
    view = function(ctx)
        return shell.row {
            shell.row { shader = shell.shader("shaders/glow.frag"),
                        uniforms = { color = "#28e6ff", strength = 0.9 }, radius = 9, ... },
        }
    end,
}
  • shell.shader(path) finds a fragment shader by absolute path, next to the config, or in the data directory, which ships shaders/aurora.frag and shaders/glow.frag. shell/examples/aurora.lua puts both on the default UI.
  • A surface shader (shader on shell.bar/shell.popup) covers the whole surface. Its uniforms may be a table or a function returning one, called on every repaint.
  • A widget shader (shader on a widget) covers the widget’s rectangle after the surface is drawn. Its uniforms is a table.
  • Both receive the surface’s cairo drawing as u_tex, so they can keep, tint, distort or replace it. A shader that fails to compile is logged and the content is drawn as if it had none.

Shaders declare only the uniforms they use. The shell supplies:

UniformType
u_texsampler2Dthe surface’s drawing, premultiplied RGBA
u_timefloatseconds since the shell started
u_sizevec2the effect’s size in logical px
u_rectvec4its x, y, width, height within the surface
u_resolutionvec2its size in buffer px
u_scalefloatbuffer scale
u_mousevec2pointer position relative to the effect, -1 when outside the surface
u_hoverfloat1 while the pointer is inside the effect
u_radiusfloatthe widget’s radius

and two varyings: v_uv, the surface position to sample u_tex at, and v_local, running 0..1 across the effect (both with y pointing down). A precision statement is added for you.

Lua uniforms become u_<name>: a number is a float, a colour a vec4, and a list of 1–4 numbers a float to vec4.

Output premultiplied colour, like u_tex. A shader that declares u_time is animated: the shell composites it every frame from the last drawing, without running any view, so an animated bar costs GPU time but almost no CPU. Shader files are watched with the config, and saving one reloads it.

Every one of those frames also makes the compositor draw the screen again, which on a laptop keeps the GPU awake. shell.shader_fps(n) composites animated shaders at most n times a second (0, the default, is every frame) and returns the cap; called without an argument it only returns it. SHADY_SHELL_SHADER_FPS sets the default, which a reloaded config starts from. A slow drift (clouds, an aurora) looks the same at 10–20.

Compositor values

shell.compositor_value(key[, fallback]) returns a value the compositor published, from its Lua (shady.publish) or a compositor plugin (publish_value), and views that read it repaint when it changes. The shell follows them over the IPC socket (“, set for programs the compositor starts) and reconnects if the compositor restarts it. This is how a bar follows a rice’s state, such as the current hour or palette:

local accent = shell.compositor_value("afterglow.accent", shell.theme.accent)

Native plugins

Function
shell.plugin(name[, options])load a native plugin once per shell process; returns true, or false and a message
shell.value(key[, fallback])a value a plugin published ("sysinfo.cpu"); views reading it repaint when it changes
shell.action(name[, argument])run a plugin action; returns false if none is registered
shell.widget(type, props)a widget drawn by a plugin, sized with width/height or by its container

Plugins outlive config reloads. Writing them is covered in SHELL_PLUGIN_API.md; shell/examples/sysinfo.lua adds a CPU graph to the default bar with the bundled sysinfo plugin, through the default UI’s shell.options.bar_extra hook.

Frosted glass

Shader effects in the shell cannot see what is behind a surface. The compositor can: in spatial mode, shady.layer_effect(name, { blur = 18 }) in the compositor’s init.lua blurs the scene behind every layer surface whose namespace is name. A bar’s or popup’s namespace is its name here ("shady-shell", "quick", "menu", "launcher" in the default UI). Glass shows through translucent backgrounds, so pair it with shell/examples/glass.lua, which sets shell.options.bar_opacity and panel_opacity. See LUA_API.md for the options.

3D placement

The compositor can also tilt, turn or recede any layer surface in spatial mode, with clicks mapped to where it is drawn: shady.layer_transform("shady-shell", { tilt = -30, depth = 40 }) in the compositor’s init.lua leans the default bar back from its top edge. Like layer_effect, it selects surfaces by namespace. See LUA_API.md.