Getting Started

Directory layout, minimal working config, CLI commands, hot-reload, and standalone compilation.

Most Wayland shells make you spend an afternoon fighting a bundler, installing 400MB of JS packages, or copy-pasting bash one-liners into a JSON file that explodes if you leave a trailing comma.

Shlua is one native binary. Point it at a folder of .lua and .css files, and it compiles your config into cached LuaJIT bytecode in milliseconds, generates live IDE autocomplete types for your own components, and runs directly against GTK4 and gtk4-layer-shell.


Building Shlua

Requirements: luajit, gcc, pkg-config, gtk4, gtk4-layer-shell, libsoup-3.0, wayland-client, and wayland-protocols.

# Build the native binary at ./build/bin/shlua
make build

# Run the included test config with hot-reload + live inspector
make debug

# Wipe build artifacts and user bytecode cache
make clean

Note: libgtk4-layer-shell is linked first inside the native binary, so you never need LD_PRELOAD=/usr/lib/libgtk4-layer-shell.so workarounds.


Config Directory Layout

By default, Shlua loads $XDG_CONFIG_HOME/shlua (or ~/.config/shlua). You can also pass any directory path directly (shlua ./my-shell).

~/.config/shlua/
├── shlua.config.lua     # Optional: directory layout, route triggers, and built-in daemon toggles
├── globals.lua          # Optional: shared reactive state & helper functions (auto-locked after load)
├── args.lua             # Optional: custom CLI flags/positionals for your shell or compiled app
├── style.css            # Global GTK4 CSS stylesheet (overrides Shlua's built-in theme tokens)
├── components/          # Auto-discovered reusable user components + co-located popup/ & modal/ routes
│   ├── StatusPill.lua   # Becomes global `StatusPill { ... }` everywhere — zero require()
│   ├── MediaCard/       # Folder form: init.lua + optional style.css, globals.lua, popup/, modal/
│   └── popup/           # Root-level overlay routes (`actions = { route = "popup:audio" }`)
├── render/              # Root surfaces (Bar, Window, LayerWindow, Hotspot) — all files load automatically
│   └── TopBar.lua
├── instances/           # Optional: standalone sub-apps launched via `shlua run` or `shlua compile`
└── .cache/              # Auto-managed bytecode cache (`config.bc`) + IDE types (`components.meta.lua`)

Tip: If you don't want a render/ folder yet, a single init.lua at the root of your config works too.


Minimal Working Config

1. shlua.config.lua (optional)

Use Config { ... } to enable managed daemons (notifications, OSD, tray) or customize overlay routes:

Config {
	routes = {
		popup = { dir = "popup", trigger = "onPress" },
		modal = { dir = "modal", trigger = "onPress" }
	},

	defaultTriggers = {
		Input = "onSubmit"
	},

	services = {
		notifications = { enabled = true },
		osd = { enabled = true },
		tray = { enabled = true }
	}
}

2. globals.lua (optional)

Anything you assign here becomes shared reactive state across every file in your config. Once globals.lua finishes running, Shlua locks the global environment — accidental typos like volum = 50 throw immediately instead of silently leaking globals like normal Lua.

-- Shared reactive state
showDetails = false

-- Shared helper available everywhere without require()
function toggleDetails()
	showDetails = not showDetails
end

3. render/TopBar.lua

Top-level surfaces (Bar, Window, LayerWindow, Hotspot) register automatically. No return needed.

Bar {
	position = "top",
	spacing = 6,

	left = {
		Workspaces { type = "pills" },
		ActiveWindow {}
	},

	center = {
		Clock { format = "%a %b %e  %I:%M %p" }
	},

	right = {
		Audio { type = "slider", revealOnHover = true },
		Battery { type = "text" },
		Tray {},
		PowerMenu {}
	}
}

CLI Reference

Shlua's CLI covers daily shell execution, live development, daemon toggling, inspection, and compiling standalone native apps:

CommandWhat it does
shluaStarts ~/.config/shlua (using cached .cache/config.bc when unchanged)
shlua ./pathStarts a specific config directory
shlua --debug (-d)Bypasses .cache/, hot-reloads on .lua/.css saves, and opens the live Inspector automatically
shlua --inspect (-i)Launches with the live DOM & GTK Inspector open (without debug hot-reload)
shlua inspectToggles the live Inspector inside an already-running Shlua instance over D-Bus
shlua --checkCompiles config, runs TypeGen, verifies FFI/fonts/cache, and exits without opening windows
shlua --forceForces bytecode recompilation even if the content hash matches
shlua run <name|dir>Launches an app from instances/<name> or a direct folder path
shlua compile <target> [-o out]Bundles an instance or config directory into a standalone native executable
shlua service <name> [enable|disable|status]Persists and live-toggles built-in services (notifications, osd, tray)

Passing Custom Flags (args.lua)

Building a custom app or scriptable launcher? Drop an args.lua in your config directory:

Args {
	description = "Quick note scratchpad",
	flags = {
		title = { short = "t", type = "string", default = "Notes", desc = "Window title" },
		pinned = { short = "p", type = "boolean", desc = "Keep above other windows" }
	}
}

Then read args.title or args.pinned anywhere in your UI, and pass flags after -- (or directly on a compiled binary):

shlua run notes -- --title "Ideas" --pinned

# Or compile it into its own standalone native binary:
shlua compile notes -o ./notes
./notes --title "Ideas" --pinned

Automatic IDE Autocomplete (Zero Setup)

Other Lua configs leave your editor blind — guessing prop names and praying you spelled exclusive right.

Every time you run shlua, --debug, or --check, Shlua's static analyzer (TypeGen) scans your globals.lua, components/, overlay routes, and args.lua and writes .cache/components.meta.lua. Point LuaLS (VSCodium, Zed, Neovim) at Shlua's types/ folder + your config directory and you get full prop autocomplete and diagnostics for both built-in widgets and your own custom components.