Mochi
Mochi is a desktop shell for Wayland built around a central island, like the Dynamic Island on a phone. The island shows what matters right now: a notification, the volume you just changed, the song that started. Small round bubbles next to it keep things in view, like the music playing or missed notifications. A control center panel grows out of the island with cards and pages, and a launcher finds your apps.
It has two parts:
mochid, a daemon written in Rust. It owns every piece of state and talks to the system: D-Bus, PipeWire, logind, the compositor. It decides what the island shows.- A Quickshell UI that
mochidstarts and keeps running. It only draws what the daemon tells it to.
mochi is the command-line client. mochi ipc <module> <action> runs any module’s action, which is how you bind keys to Mochi.
Everything is a module: the clock, the notifications, the launcher. Each one can be turned off, and the island makes room for what’s left. Mochi uses standard Wayland protocols, so it works on any compositor that supports them, with extras where a compositor offers more.
Mochi is early work in progress.
How it works
Mochi is two programs that talk over a socket: mochid, a daemon written in Rust, and a user interface written in QML that runs in Quickshell. The daemon decides and the interface draws.
D-Bus, PipeWire, NetworkManager, BlueZ, UPower, logind, the compositor…
│
mochid ─── modules, the island's rules, bubbles
│
┌──────────────────────┼──────────────────────┐
Quickshell UI mochi (the CLI) plugin backends
The daemon decides, the interface draws
mochid holds every piece of state and does all the work with the system: it listens to notifications on D-Bus, reads the volume from PipeWire, asks NetworkManager for Wi-Fi networks, watches the compositor’s workspaces. It decides what the island shows and when, and tells the interface.
The interface only draws. It gets the state and the theme from the daemon and sends back what the user did: a click, a key, a drag. It holds no logic of its own beyond layout and animation.
This split is the reason Mochi exists instead of a shell written in Quickshell alone:
- The work happens in compiled Rust, outside the thread that draws. Stitching screenshots together, polling sensors and talking to D-Bus never make an animation stutter, and the QML stays small.
- The logic is tested. The rules for what shows, every module’s behavior and the configuration run in the test suite, including end-to-end tests that drive the real daemon as the interface and the CLI would.
- A crash of the interface loses nothing.
mochidstarts Quickshell, restarts it when it exits, and sends it everything again: the state, the theme, what each island shows. Notifications, the clipboard history and a recording in progress are untouched. - Everything is reachable from outside. Anything the interface can do,
mochi ipccan do from a keybind or a script.
Modules
Every feature is a module: the clock, notifications, the launcher, Bluetooth. A module has a Rust part that runs inside mochid and QML views that the interface draws. modules in config.toml lists which run, and a module that’s off costs nothing.
Modules offer things to each other through contributions: a card or a page for the control center, results for the launcher, a widget for the desktop, a step for the tour. The control center, for instance, has little of its own besides the date and time. The modules that run fill it.
At start, mochid writes the views of the modules that run into $XDG_RUNTIME_DIR/mochi/shell/ and points Quickshell at it, so what the interface loads always matches what runs.
The island
The island is the shape at the top of each screen. Modules don’t draw on it directly: they submit activities, like “a notification from Firefox” or “the volume changed”, and a set of rules picks what shows:
- One activity shows at a time. One with a higher priority interrupts a lower one, which comes back when it ends.
- Others wait their turn, by priority, then by arrival.
- An activity with a key replaces the module’s earlier one with the same key: dragging the volume updates one notice instead of queueing many.
- Timers pause while the pointer is over the island, and while it’s expanded.
Each screen has its own island and decides by itself, so a panel open on one screen doesn’t hold back a notice on another. The island has its settings.
Bubbles
Bubbles are the small round items next to the island: the music playing, a recording’s red dot, missed notifications. Modules ask for them, and the edge has five areas they fill, from left to right. A full area hides the rest behind a “+N”, or stacks them into one. Bubbles has the details.
Configuration
config.toml says which modules run and how, and theme.toml how everything looks. Mochi writes both, commented, on the first start, and never changes them. mochi reload applies them without a restart, starting, stopping and restarting only the modules that changed.
The settings panel doesn’t write those files either: it keeps its changes in changes.toml next to them, laid over them. That’s what lets it work when home-manager owns your config, and why Copy in the panel hands the changes back as Nix or TOML for your own files. Configuration has the rest.
Plugins
A plugin is a module that isn’t built into Mochi, with the same powers. It’s a manifest, mochi-plugin.toml, QML views, and usually a backend: any program, in any language, that mochid starts and talks to over a socket, with the same messages the builtin modules use. A plugin of views only can also replace a builtin view.
mochi plugins install fetches and builds them, and shows what each one will run before asking. Plugins covers using them, and Writing plugins making one.
Bento
Bento shares what you made: a theme, a plugin, or a whole setup, from a reviewed registry or anyone’s repository. It’s off until you turn it on, and each setup you install is one you can switch to and back from.
Compositors
Mochi reads workspaces, windows and screens through standard Wayland protocols, like ext-workspace-v1 and wlr-foreign-toplevel-management, so it works on any compositor that has them: Hyprland, niri and Sway. Where a compositor offers more through its own IPC, Mochi uses it: Hyprland, for example, tells it what’s being shared on screen, and Hyprland, niri and Sway tell it the keyboard layout, which no protocol says. mochi doctor says what yours offers.
Talking to it
Everything goes through the socket in $XDG_RUNTIME_DIR/mochi/mochi.sock, one JSON message per line. The interface, the mochi command and plugin backends are its three kinds of client. Protocol describes the messages.
Installing
Nix
The flake has the mochi package, with both binaries, the systemd unit and the Quickshell version mochid expects. It also has a home-manager module, a NixOS module and an overlay. Add it to your flake’s inputs, pinned to a release:
mochi = {
url = "github:Davidutz19/mochi/v0.4.7";
inputs.nixpkgs.follows = "nixpkgs";
};
With follows, Mochi builds with your nixpkgs, which needs Rust 1.98 or newer. Quickshell stays pinned by Mochi’s own lock file either way.
home-manager
Import inputs.mochi.homeModules.default, then:
programs.mochi = {
enable = true;
# config.toml, as Nix. Leave it out and Mochi writes its commented
# example on the first start instead.
settings = {
# Every builtin module runs without this; list them to pick fewer.
# modules = [ "idle" "osd" "workspaces" "media" "launcher" "control-center" ];
module.idle.format = "HH:mm:ss";
module.power.lock = [ "hyprlock" ];
bubbles.media.area = "center-left";
};
# theme.toml, the same way.
theme = {
colors.accent = "#8aadf4";
layout.mode = "notch";
};
};
The option names are the ones in the configuration pages: [module.idle] becomes module.idle. mochi config init --print shows every option with its default.
home-manager switch checks both files with mochid config check, so a typo fails the switch with the same error the daemon would give, instead of breaking the shell. When they change, the switch runs mochi reload; the shell doesn’t restart.
The module starts mochid as a user service with wayland.systemd.target, which is graphical-session.target unless you changed it. Set programs.mochi.systemd.target to use another target, or programs.mochi.systemd.enable = false to start it yourself.
If Mochi already wrote a config.toml or theme.toml, home-manager refuses to replace it. Move the file away, or keep it with home-manager’s -b backup.
NixOS
Import inputs.mochi.nixosModules.default, then:
programs.mochi.enable = true;
This installs Mochi for every user and starts it with each user’s graphical-session.target. Each user’s settings stay in ~/.config/mochi, or in the home-manager module. Use one module or the other, not both.
Recording
The package brings gpu-screen-recorder, which the capture module records with. With home-manager, setting module.capture.recorder in settings leaves it out. To record a region or a whole screen, gpu-screen-recorder also needs a helper with extra permissions, which only the system can install. The NixOS module enables it; set programs.mochi.recording.enable = false to skip it. With home-manager alone, add this to your NixOS configuration:
programs.gpu-screen-recorder.enable = true;
The overlay
inputs.mochi.overlays.default adds pkgs.mochi, for setups that list packages themselves.
Without building
mochi compiles on your machine whenever its input changes. mochi-bin is the latest release instead, already built: Nix downloads the archive, patches its binaries to find your libraries, and wraps them like mochi, so nothing compiles.
programs.mochi.package = inputs.mochi.packages.${pkgs.stdenv.hostPlatform.system}.mochi-bin;
It’s the release packaging/nix/release.json names, which the release workflow updates on main after it publishes. So follow main, github:Davidutz19/mochi, rather than a tag: a tag’s commit was made before its release existed.
Arch Linux
The repository has three packages in packaging/arch, with the same files:
mochibuilds the latest release.mochi-bininstalls the latest release already built, from its archive, so nothing compiles, and needs nocargo.mochi-gitbuilds the latest commit onmain.
They conflict with each other: install one.
They aren’t on the AUR yet. Until they are, build one from the repository with makepkg, which needs base-devel and git:
git clone https://github.com/Davidutz19/mochi.git
cd mochi/packaging/arch/mochi-bin # or mochi to build it, or mochi-git
makepkg -si
makepkg -si installs the missing dependencies, builds the package and installs it with pacman. To update mochi-git, run makepkg -si again in the same folder: it fetches the latest commit itself. For mochi, git pull first, to get the PKGBUILD of the newest release.
Once they’re on the AUR, paru -S mochi or yay -S mochi does the same.
Both depend on quickshell, gpu-screen-recorder and inter-font from the official repositories, and download the Material Symbols icon font from Google’s repository, pinned to one commit. The build runs the test suite. They install mochid, mochi, the systemd user unit, mochi-share-picker and mochi-askpass. mochi-bin takes both fonts from the release archive instead, so it doesn’t need inter-font. Optional dependencies:
wl-clipboard, to copy screenshots.satty, the default screenshot editor.uwsm, to start apps from the launcher as units of their own. Without it, the launcher usessystemd-run.xdg-desktop-portal-hyprland, for the share module.
Then start the shell with your session:
systemctl --user enable --now mochid
The unit needs a session manager such as uwsm; see the session. On the first start, Mochi writes a commented ~/.config/mochi/config.toml. mochi config init --print shows every option with its default.
Arch’s gpu-screen-recorder package already gives its helper the permissions it needs to record a region or a whole screen, so recording needs no more setup.
To use the share module’s picker, point the portal at it in ~/.config/hypr/xdph.conf, then restart the portal with systemctl --user restart xdg-desktop-portal-hyprland:
screencopy {
custom_picker_binary = /usr/bin/mochi-share-picker
}
The PKGBUILDs live in packaging/arch. When Quickshell in the official repositories moves past the version mochid expects, mochid refuses to start until a Mochi release follows it.
From a release
On a system without a package for Mochi, one command installs it, and updates it when you run it again:
curl -fsSL https://raw.githubusercontent.com/Davidutz19/mochi/main/install.sh | sh -s -- --enable
It downloads the latest release built for your machine, x86_64 or aarch64 Linux with glibc 2.35 or newer, checks it against its published sum, and installs it into ~/.local: the binaries, the fonts, the systemd unit, the mochi:// link handler and shell completions. --enable starts mochid with your session through systemd. Run the same command later to update: it does nothing when the latest is installed, and restarts a running mochid after updating.
Options go after sh -s --:
| Option | |
|---|---|
--prefix /usr/local | Install there, with sudo sh -s -- --prefix /usr/local, instead of ~/.local |
--version 0.4.7 | A given release instead of the latest |
--enable | Start mochid with the session |
--uninstall | Remove what it installed |
--force | Install even when the same version is there, or when a package manager installed Mochi |
MOCHI_FROM_SOURCE=1 builds the release from source with cargo instead of downloading it, and MOCHI_FROM_SOURCE=main builds the latest commit, for systems the releases don’t cover. That needs git, cargo with Rust 1.98 or newer, pkg-config and libpulse’s headers:
curl -fsSL https://raw.githubusercontent.com/Davidutz19/mochi/main/install.sh | MOCHI_FROM_SOURCE=1 sh
Mochi installed by Nix, pacman, apt or rpm is left to that package manager: the installer says so and stops, unless --force.
Either way, Mochi needs Quickshell 0.3 and PulseAudio’s library, libpulse, which PipeWire systems have too, from your distribution.
By hand, each release on GitHub has mochi-<arch>-linux.tar.gz with a .sha256; unpack it and run its install.sh, which takes --prefix and --uninstall too.
Other systems
Build it yourself:
cargo build --release
sudo install -m755 target/release/mochid target/release/mochi /usr/bin/
install -Dm644 systemd/mochid.service ~/.config/systemd/user/mochid.service
systemctl --user enable --now mochid
mochid needs Quickshell 0.3.1 in its PATH, and refuses to start with another version.
The session
The unit starts with graphical-session.target. Session managers such as uwsm start that target and give the user manager WAYLAND_DISPLAY. Without one, start mochid from your compositor’s autostart instead; it doesn’t need systemd.
Logs are in journalctl --user -u mochid. MOCHI_LOG=debug shows everything the daemon decides.
Compositors
Workspaces come from the standard ext-workspace-v1 protocol, so the workspace indicator works on any compositor that supports it. The focused monitor comes from the focused window, through wlr-foreign-toplevel-management; on Hyprland, its event socket makes that exact. mochi status shows what the daemon found.
Getting started
The first start
The first time mochid starts, it writes two files to ~/.config/mochi/:
config.toml: which modules run, and their settings.theme.toml: colors, sizes and motion.
Every option is in them, commented, with its default. They turn on the whole shell: the clock, the on-screen display, workspaces, media, notifications, the launcher, the control center, the power page and screenshots. Mochi never overwrites these files.
mochi config path # where the files are
mochi config check # check them, without a running daemon
mochi reload # apply your changes, without a restart
mochi doctor # check everything Mochi needs around it
mochi profile # record what Mochi costs for 30 s, as a report to send
mochi doctor checks what Mochi needs around it and says what to install or change: whether mochid runs and the UI is connected, the config, Quickshell’s version, the fonts, which Wayland protocols your compositor offers and what each is for, the portal and its share picker, whether another notification daemon holds the name, and the programs your modules and plugins run, like gpu-screen-recorder or satty. Each line is ✓ fine, ! something works less well, or ✗ broken, and the command fails when one is broken.
Keys
Mochi doesn’t grab keys itself. Bind these in your compositor:
| Action | Command |
|---|---|
| Open or close the launcher | mochi ipc launcher toggle |
| Open or close the control center | mochi ipc control-center toggle |
| Open or close the clock, with the calendar and reminders | mochi ipc clock toggle |
| Play or pause the music | mochi ipc media play-pause |
| Do not disturb | mochi ipc notifications dnd toggle |
| Lock the screen | mochi ipc power lock |
| Take a screenshot | mochi ipc capture screenshot |
| Start or stop recording | mochi ipc capture record |
| Close what the island shows | mochi dismiss |
mochi ipc lists every action of every module, and mochi ipc <module> one module’s.
Escape closes views that take the keyboard: the launcher, the control center, the mixer, the clipboard and the other panels. Notices that let you keep typing, like the volume or a notification, don’t take it, so Escape goes to your app; mochi dismiss on a key like SUPER + Escape closes those, and a right click on the island does too.
In Hyprland’s Lua config:
hl.bind("SUPER + space", hl.dsp.exec_cmd("mochi ipc launcher toggle"))
hl.bind("SUPER + C", hl.dsp.exec_cmd("mochi ipc control-center toggle"))
hl.bind("SUPER + period", hl.dsp.exec_cmd("mochi ipc clock toggle"))
hl.bind("SUPER + SHIFT + N", hl.dsp.exec_cmd("mochi ipc notifications dnd toggle"))
hl.bind("Print", hl.dsp.exec_cmd("mochi ipc capture screenshot"))
hl.bind("ALT + Print", hl.dsp.exec_cmd("mochi ipc capture record"))
-- `locked` keeps media keys working on the lock screen.
hl.bind("XF86AudioPlay", hl.dsp.exec_cmd("mochi ipc media play-pause"), { locked = true })
hl.bind("XF86AudioNext", hl.dsp.exec_cmd("mochi ipc media next"), { locked = true })
hl.bind("XF86AudioPrev", hl.dsp.exec_cmd("mochi ipc media previous"), { locked = true })
In hyprland.conf:
bind = SUPER, space, exec, mochi ipc launcher toggle
bind = SUPER, C, exec, mochi ipc control-center toggle
bind = SUPER, period, exec, mochi ipc clock toggle
bind = , Print, exec, mochi ipc capture screenshot
bindl = , XF86AudioPlay, exec, mochi ipc media play-pause
In Sway:
bindsym $mod+space exec mochi ipc launcher toggle
bindsym $mod+c exec mochi ipc control-center toggle
bindsym $mod+period exec mochi ipc clock toggle
bindsym Print exec mochi ipc capture screenshot
bindsym --locked XF86AudioPlay exec mochi ipc media play-pause
In niri:
binds {
Mod+Space { spawn "mochi" "ipc" "launcher" "toggle"; }
Mod+C { spawn "mochi" "ipc" "control-center" "toggle"; }
Mod+Period { spawn "mochi" "ipc" "clock" "toggle"; }
Print { spawn "mochi" "ipc" "capture" "screenshot"; }
XF86AudioPlay allow-when-locked=true { spawn "mochi" "ipc" "media" "play-pause"; }
}
The command line
mochi completions <shell> prints completions for bash, zsh, fish, elvish or PowerShell; the Nix and Arch packages install them for bash, zsh and fish. --json makes mochi status, mochi ipc list, mochi ipc <module> and mochi plugins list print JSON, for scripts:
mochi status --json | jq -r '.modules[]'
Using the island
- A left click expands what the island shows, or collapses it; clicking the clock opens the control center.
- A right click closes it.
- Hovering keeps it from timing out.
- Clicking a bubble opens what it stands for: the music bubble shows the player, the bell shows missed notifications.
Another notification daemon
If swaync, mako or dunst is running, Mochi waits behind it and takes over notifications when it stops. To switch, stop the other one, for example with systemctl --user disable --now swaync.
Configuration
Mochi reads two files in ~/.config/mochi/ (or $XDG_CONFIG_HOME/mochi/):
config.toml: which modules run, and their settings.theme.toml: how everything looks. See Theme.
Both are written on the first start, with every option commented. A line like # timeout_ms = 1500 shows a default: remove the # to change it. Anything left out keeps its default, so a file can be as short as the one line you change.
Mochi writes a few files next to them itself: changes.toml with the settings panel’s changes, widgets.toml with the widgets’ layout, and bento.toml with what Bento installed.
Checking and applying
mochi config check checks both files with the same rules mochid uses, without a running daemon. Every error names the file, the section and the key:
config.toml: [module.osd]: unknown field `timeot_ms`, expected one of `timeout_ms`, `volume`, `device`, `microphone`, `locks`
mochi reload applies both files to the running daemon. Modules you added start, modules you removed stop, and modules whose settings changed restart; the others keep running. A file with an error changes nothing, and mochi reload prints the error.
The settings panel changes the same options live. It keeps its changes in changes.toml next to the two files, laid over them, and gives them back as Nix or TOML to paste into your files.
mochi config init writes the example files where they’re missing, and mochi config init --print shows them without writing.
Modules
modules = ["idle", "osd", "workspaces", "media", "notifications", "launcher", "control-center", "power"]
The modules to run, in this order. Without modules, every builtin module runs, so a new install has the whole shell; list them to pick fewer. The focus timer, the lock screen and auth are the exceptions: they run only when listed. Each module’s settings live in a [module.<id>] section; the module pages list them. A module left out of the list doesn’t run, and its section is ignored.
mochid --modules idle,osd overrides the list for one run, which helps when trying things.
The island
# The island.
[island]
# Which monitor panels open on: the launcher, the control center, the
# clipboard and the other views you type into. "focus" is the monitor with
# keyboard focus, "pointer" the one under the mouse (on Hyprland; elsewhere
# it's "focus"), and "all" every monitor at once.
# panels = "focus"
# Which monitor everything else shows on: notifications, the volume, the
# media card and every other notice. "all" is every monitor's island at
# once; "focus" and "pointer" as for panels, while the other monitors keep
# the idle island.
# notices = "all"
# What a click outside the island closes. "all" is whatever the island
# shows, except the idle island and quick notices like the volume; the
# click closes it instead of reaching the window under it. "expanded" is
# only views you opened with a click, and the ones you type into.
# click_outside = "all"
Each monitor has an island of its own, which decides what it shows by itself: a panel open on one monitor doesn’t hold back a notice on another, and the workspace indicator shows on the monitor that switched. What isn’t meant for one monitor, like the idle clock, shows on every island; closing it on one closes it everywhere.
panels decides where the views you type into open. On Hyprland, "pointer" asks the compositor where the mouse is; elsewhere it opens them where the keyboard is.
notices does the same for everything else the island shows: notifications, the volume, workspace switches, the media card, any module’s notice. With "focus" or "pointer", a notice shows on that one monitor’s island, picked when it comes, and waits only behind what that island shows; the others go on with their own. The default, "all", shows it on every monitor’s island.
click_outside decides what a click outside the island closes. With "all", a notification you never opened goes to the missed ones, as if its time had run out, and the media card goes back to its bubble. The volume and workspace notices never catch clicks, since they show while you’re busy elsewhere. While a notice you didn’t open catches clicks, it also takes the scroll wheel, since a Wayland surface can’t pass events on to the window under it. So scrolling outside it lets go, and Mochi scrolls the window under it the same way: the scroll isn’t lost, and the notice stays until its time runs out. A view you opened with a click, or one you type into, is closed for good, and takes the keyboard while it’s open so Escape closes it too.
The click that closes something isn’t lost: Mochi clicks again at the same spot once the island lets go, through the compositor’s virtual pointer (wlr-virtual-pointer-unstable-v1, which Hyprland and Sway have), so the window under it gets it the first time. Scrolling outside an open panel closes it too and scrolls the window under the pointer. While a panel is open on one monitor, a click or a scroll on another monitor closes it as well, and reaches the window there the same way. A drag that starts outside only closes.
Bubbles
Bubbles are small round status items next to the island, like the music playing or missed notifications. The screen edge has five areas, from left to right: left, center-left, center, center-right and right. The island sits in one of them, center unless the theme says otherwise.
Each module places its bubbles where it thinks best. Settings › Bubbles shows the five areas side by side with a bubble for each module that has some, a dot on the ones showing now, and the island where it sits. Drag a bubble to sort it within its area or to move it to another area, or drag it to Hidden to stop it showing. Click one for its options: shown or not, with text when its module has a wide view, kept out of a merged shape, and which bubble it shares a pill with. With the keyboard, Tab to a bubble, then use Left and Right to sort it, Shift with Left or Right to move it to the next area, Delete to hide it, and Enter for its options.
The page writes what you arrange to config.toml’s [bubbles] sections, which you can also edit by hand:
# Bubbles: small round status items next to the island, like the music
# playing or missed notifications. The edge has five areas, from left to
# right: left, center-left, center, center-right and right. Each area lays
# its bubbles apart, merges them into one shape, stacks them, or merges
# them into the island's shape.
[bubbles]
# How many bubbles fit in one area; the rest hide behind a "+N".
# max_per_area = 4
# How each area draws its bubbles. "apart" gives each bubble, or each
# group, a pill of its own. "merged" draws one shape around all of them,
# each still taking its own clicks. "stacked" shows the most important in
# front with the others peeking behind it, and fans them out on hover.
# "island" merges them into the island's shape: it reaches out to them
# across the gap, even to the screen's sides, and takes in the bubbles on
# the way. In bar mode, the bar already draws one shape.
# The area against the left side of the screen.
# left = "apart"
# The area just left of the center.
# center_left = "apart"
# The middle of the edge, where the island sits unless the theme moves it.
# center = "apart"
# The area just right of the center.
# center_right = "apart"
# The area against the right side of the screen.
# right = "apart"
# How long a bubble that appears, or has news like a new missed
# notification, stays in front of its stack, in milliseconds.
# news_ms = 4000
# How long the pointer rests on a bubble before a tooltip says more about
# it, in milliseconds: the track playing, the network, who uses the
# microphone. 0 shows none.
# tooltip_ms = 600
# Each module puts its bubbles where it thinks best. Settings › Bubbles moves
# them by dragging, and writes a [bubbles.<module>] section like this one:
#
# [bubbles.media]
# area = "left" # one of the five areas
# group = "status" # same group, same pill; "" for a pill of its own
# order = 1 # lower goes further left
# wide = true # a pill with text, for modules that have one
# show = false # no bubbles from this module at all
# merge = false # its own pill beside a merged area's shape
Hidden bubbles
Past max_per_area, an area leaves out its least important bubbles and shows a “+N” pill with how many. Click it and the island lists them, each drawn as its module draws the bubble, with text when the module has a wide view. Click one to do what a click on the bubble does; the list closes. Escape, a click outside or a second click on “+N” closes it too. The list follows changes while it’s open, and closes when the area has room for everything again.
Merging
An area set to "merged" draws one shape around its bubbles instead of a pill for each. Each bubble keeps its own clicks, tooltip and a highlight under the pointer. In notch mode the shape hangs from the edge like the island, with ears at its ends; against the screen’s side it meets that side too.
"island" merges the area into the island’s shape instead of a shape of its own. The island’s shape reaches out to the area wherever it is, across the gap to the screen’s side too, so right = "island" makes one notch, or one floating pill, from the island to the bubbles at the right edge. Bubbles of other areas on the way draw on that shape as well. A panel the island opens grows out of it the way it grows out of the bar.
merge = false in a module’s [bubbles.<module>] keeps its bubbles in pills of their own, beside the shape on the side away from the island.
In bar mode the bar already draws one shape for everything, so merging changes nothing there.
Stacking
"stacked" shows one bubble instead of a row: the most important in front, and up to two more peeking out behind it, smaller, on the side away from the island. Hover the stack and it fans out into the row, each bubble clickable; it folds back a moment after the pointer leaves.
A bubble with news comes to the front for news_ms, 4 seconds by default, then goes back behind the most important one. News is a bubble appearing, or a change its module calls news: one more missed notification, another network, a device connecting, the battery turning critical, an app asking for attention in the tray, a reading turning critical. Changes that come all the time, like a timer or the CPU’s use, never do. A module marks a showing as news with BubbleSpec::news(); a bubble’s priority decides which is in front otherwise.
Resting the pointer on a bubble for tooltip_ms, 600 milliseconds by default, shows a tooltip beside it with more: the track and the artist, the network and its VPN, the battery’s time left, who uses the microphone or the camera, how far a conversion is. tooltip_ms = 0 turns them off. A module sets one with BubbleSpec::tooltip(text), and a bubble’s view can work one out from its payload with a tooltip property, which wins.
A stack holds every bubble of its area, so max_per_area doesn’t apply to it.
Before each area had its own setting, stack = true stacked every area. It still stacks the areas config.toml doesn’t set; an area it sets wins.
Theme
theme.toml sets how everything looks, for every module at once. Views only use these values, never their own, so a change here restyles the whole shell. mochi reload applies it at once.
The defaults are “Obsidian”: a black island that disappears into the screen’s bezel, graphite cards on it, and one accent color for what’s active or important.
Presets and light mode
preset picks a theme, a color for every role: obsidian, catppuccin, nord, gruvbox, rose-pine, tokyo-night, or one you installed, see Theme packages. Each has a dark and a light version, which appearance picks: "dark", "light", or "auto" to follow the system’s preference through the desktop portal, switching as it changes. What [colors] sets goes over the preset, so you can keep a preset and change only the accent.
preset = "wallpaper" makes the palette from your wallpaper: the accent from its most colorful hue, and the backgrounds from the same hue nearly grey, with lightness chosen so text stays readable. wallpaper = "auto" reads the image, or the plain color, that awww, swww or hyprpaper shows; a path reads that image. mochi reload reads it again after the wallpaper changes.
The settings panel lists the presets with their colors, and applies them as you pick. A preset picked there replaces the colors [colors] sets, in the file and in the panel, so you see that theme. Copy then gives the preset without them, for your own files.
Theme packages
A theme is a directory with a mochi-theme.toml. Installed ones live in ~/.local/share/mochi/themes/<id>/ ($XDG_DATA_HOME/mochi/themes), and preset = "<id>" picks one like the themes Mochi brings, which are written the same way:
[theme]
id = "nord"
name = "Nord"
version = "1.0.0"
mochi = "0.0.8"
description = "Arctic blues and frost"
authors = ["Mochi"]
homepage = "https://www.nordtheme.com"
[dark]
background = "#f52e3440"
surface = "#3b4252"
raised = "#434c5e"
highlight = "#4c566a"
foreground = "#eceff4"
muted = "#a3abb9"
accent = "#88c0d0"
on_accent = "#2e3440"
danger = "#bf616a"
success = "#a3be8c"
border = "#0dffffff"
shadow = "#59000000"
[light]
background = "#f5eceff4"
surface = "#e5e9f0"
raised = "#d8dee9"
highlight = "#c8d0dc"
foreground = "#2e3440"
muted = "#4c566a"
accent = "#5e81ac"
on_accent = "#eceff4"
danger = "#bf616a"
success = "#6f8f55"
border = "#1a000000"
shadow = "#26000000"
[theme] says what it is. id is lowercase letters, digits, - and _, starting with a letter, and must match the directory’s name. name is what the settings panel shows, and mochi is the oldest Mochi it works with: a newer one is refused, and mochi config check says so. description, authors and homepage are optional.
[dark] and [light] give each role a color, the roles of [colors] below. A theme with only one of them uses it for both appearances, so a dark theme stays dark, and a role it leaves out takes Obsidian’s of the same version, so a theme can be as short as an accent. Like every theme, it holds no views or code, so it can’t run anything. A typo, like an unknown role or a color that isn’t #rrggbb or #aarrggbb, is an error naming the key.
A theme can also set the rest of the look, with the sections theme.toml has below: [text] for its fonts and sizes, [layout] for the island’s shape and spacing, and [motion] for how things move. What your theme.toml sets goes over them, and the settings panel shows the theme’s values where you set nothing:
[text]
family = "IBM Plex Sans"
[motion]
speed = 1.5
They’re checked like theme.toml, so a typo or a value out of range is an error naming its section. A font the theme names that isn’t installed is drawn in another font Qt picks, so install the fonts a theme names.
mochi bento add <directory or repository> installs a theme, and mochi bento try tries it until you keep it or drop it: see Bento.
Layout
[layout] mode picks the island’s shape. "island" floats it margin away from the edge, rounded all around. "notch" attaches it to the edge, square there, with concave corners, the ears, flaring into the edge. "bar" draws a strip idle_height tall along the whole edge, like GNOME’s or macOS’s top bar: the bubbles sit on it without a background of their own and light up under the pointer, and the island sits in it, so the idle clock reads as part of the bar. A notice or a panel grows out of the bar like a notch, with ears where it leaves it. Windows keep out of the strip, and switching modes morphs from one to the other.
Motion
[motion] sets how things move. reduced = true turns animations off: views appear and change at once, and the island takes its shape without a spring. speed makes every animation faster or slower, 2 being twice as fast.
Some progress lines and rings wave while something goes on: the media line while a track plays, the battery ring while it charges, the timer’s ring while it runs, and the performance rings. waves = false draws every one of them flat. To keep some and not others, leave it on and turn off a module’s own: wavy = false in [module.media], [module.battery] or [module.performance]. With reduced = true the waves stay, but the media line’s stops drifting.
Text is set in Inter and icons in Material Symbols Rounded, which the Nix and Arch packages bring; text.family picks another font. Sizes follow one scale: four text sizes and one for big numbers, five spacings and three corner sizes, so every module lines up. text.label and text.subtitle, from before the scale, still work as text.caption and text.body, and mochi config check says so.
# Mochi's look. mochid wrote this file because there was none, and it never
# overwrites it. A line like "# accent = ..." shows a default: remove the
# "# " to change it. `mochi reload` applies changes at once.
#
# Colors are #rrggbb or #aarrggbb (aa is the opacity, ff for opaque).
# A theme: obsidian, catppuccin, nord, gruvbox, rose-pine, tokyo-night, one
# installed in ~/.local/share/mochi/themes, or wallpaper, made from your
# wallpaper. What [colors] sets below goes over it, until the settings panel
# picks another preset, which replaces those colors.
# preset = "obsidian"
# "dark" or "light", or "auto" to follow the system's preference.
# appearance = "dark"
# The image the wallpaper preset reads, or "auto" for the one awww, swww or
# hyprpaper shows. A new image there counts once the settings apply again.
# wallpaper = "auto"
[colors]
# The island and the control center panel.
# background = "#f5000000"
# Cards and tiles on the background.
# surface = "#1c1c1e"
# Buttons, tracks and dividers, one step above surface.
# raised = "#2c2c2e"
# Hovered buttons, one step above raised.
# highlight = "#3a3a3c"
# Text and icons.
# foreground = "#ffffff"
# Secondary text and icons.
# muted = "#8e8e93"
# What is active or important, and nothing else.
# accent = "#ff9f0a"
# Text and icons on the accent color.
# on_accent = "#000000"
# Destructive actions, like a shut down waiting for its second click.
# danger = "#ff453a"
# success = "#30d158"
# The hairline around the island and the bubbles; transparent for none.
# border = "#0dffffff"
# The soft shadow under them; transparent for none.
# shadow = "#59000000"
[layout]
# "island" floats apart from the screen edge; "notch" attaches to it with
# curved corners; "bar" is a strip along the whole edge with the bubbles on
# it, and the island grows out of it.
# mode = "island"
# "top" or "bottom".
# anchor = "top"
# The area the island sits in: left, center-left, center, center-right or right.
# island = "center"
# Gap to the screen edges in island mode, in pixels.
# margin = 6
# Gap between the island and bubbles.
# spacing = 8
# Height of the idle island and of bubbles. Windows make room for this much.
# idle_height = 34
# padding = 14
# The island's largest corner radius; short islands become round pills.
# max_radius = 34
# Corners of small controls, of rows and buttons, and of cards and tiles.
# radius_small = 8
# radius_medium = 14
# radius_large = 20
# The tallest the island can grow, in pixels.
# surface_height = 640
[layout.notch]
# Size of the curves where the notch meets the edge, and where the island
# leaves the bar.
# ear_radius = 10
[motion]
# Turn animations off: views appear and change at once, and the island takes
# its new shape without a spring.
# reduced = false
# How fast every animation runs: 2 is twice as fast, 0.5 half as fast.
# speed = 1.0
# The island's resize spring: stiffness, and damping between 0 and 1
# (lower bounces more).
# spring = 4.0
# damping = 0.32
# How views fade when the island changes, in milliseconds.
# fade_in_ms = 220
# fade_out_ms = 120
# fade_delay_ms = 90
# Color and hover changes.
# fast_ms = 150
# Things moving inside a view, with a slight overshoot.
# move_ms = 350
# Progress lines and rings wave while something goes on, like the media line
# while a track plays. Off draws every one of them flat.
# waves = true
# How far a mouse wheel's step scrolls a list, in pixels.
# scroll_step = 120
# A wheel's steps glide instead of jumping, and a touchpad's scroll coasts on
# after the fingers lift.
# smooth_scroll = true
[text]
# A font family name; empty uses Inter, which Mochi's packages bring, or
# the system font without it.
# family = ""
# The font of the clocks, on the idle island and in the control center;
# empty uses the font above.
# display_family = ""
# The type scale, in pixels: labels and fine print, everything else, titles,
# page titles, and big numbers like a clock.
# caption = 11
# body = 13
# title = 15
# headline = 20
# display = 42
Plugins
Plugins add modules to Mochi. A plugin can do anything a builtin module does: show activities on the island and bubbles next to it, offer cards and pages to the control center, answer mochi ipc actions, publish state for its views, read other modules’ state, and replace builtin views. A plugin is views in QML, usually with a backend: a program mochid starts and talks to. Writing plugins shows how to make one: Mochi’s SDK writes backends in Rust, and any language works.
Plugins are trusted code, like the apps you install. Their views can run commands and their backends run as you, so install plugins you trust.
Listing plugins
Plugins are listed in plugins.toml, next to config.toml in ~/.config/mochi/, by id:
[plugins.pomodoro]
source = "git:github.com/User/mochi-pomodoro:main"
[plugins.meteo]
source = "git-release:github.com/User/mochi-meteo:v0.2.0"
[plugins.clock]
source = "https://example.org/mochi-clock-1.0.tar.gz#sha256=9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
[plugins.mine]
source = "path:~/code/my-plugin"
mochi bento add installs plugins too, and lists them in bento.toml next to plugins.toml, which counts as if plugins.toml listed them: see Bento.
The source says where the plugin comes from and how it’s installed:
| Source | Installs |
|---|---|
git:<host>/<user>/<repo>:<ref> | Clones the repository and builds the plugin with the command in its manifest. <ref> is a branch, a tag or a commit; without :<ref>, the default branch. A URL with a scheme works too: git:https://codeberg.org/User/repo:v1. |
git-release:<host>/<user>/<repo>:<tag> | Downloads the release asset the plugin’s manifest names, already built: nothing to compile. Without :<tag>, the latest release. The host is GitHub, a Forgejo or Gitea like codeberg.org, or a GitLab, where <user> can be a group and its subgroups: git-release:gitlab.com/Group/Sub/repo. Mochi knows github.com, codeberg.org, gitea.com and gitlab.com, and asks another host’s API which of them it runs. |
https://<url>#sha256=<hash> | Downloads a tar archive, compressed or not, checks its SHA-256, and installs what it holds like a path: directory: built with its manifest’s command, or as it is when the backend is built already. The hash is required, and sha256sum prints it; an archive with another hash is refused. |
path:<dir> | Uses the directory where it is, building it in place. For writing a plugin: its views hot-reload. ~ is your home directory, and a relative path starts next to plugins.toml. |
bento:<id>, bento:<id>:<version> | Installs from Bento’s registry: the newest release this Mochi runs, or the version named, at the commit its reviewers read. bento:<registry>/<id> uses another registry. |
Which source to pick
A git: source builds the plugin on your machine, so it needs the plugin’s own build environment: the compiler or runtime of its language, like cargo, go, node or python3, the libraries it links, and the programs its backend runs. Mochi brings none of these. The Nix package only brings git, curl and tar, which install itself uses. A release needs none of it, since the plugin comes built.
| You have | Use |
|---|---|
| The plugin’s build tools | git:, or a release if it has them |
| No build tools, and the plugin publishes releases | git-release: |
| NixOS, or Nix on another system | git: or home-manager’s src for the languages below; a release for the others |
On NixOS, and with Nix
NixOS has no build tools installed by default, and doesn’t put libraries where a build looks for them. So with Nix installed, Mochi builds plugins with Nix itself, from the lock file the plugin already has, without its author writing any Nix:
| Language | Built from |
|---|---|
| Rust | Cargo.lock |
| Node | package-lock.json |
| Python | pyproject.toml or requirements.txt, with packages from nixpkgs |
| Go | go.mod with vendor/ committed |
| Scripts, and release archives | The files as they are; release binaries are patched to find NixOS’s libraries |
mochi plugins install does this when the plugin’s build tools, or the programs it needs, aren’t installed, and always when the plugin has a flake.nix. Home-manager does it for src, see With home-manager. The build stays in the Nix store, kept from garbage collection by a link in ~/.local/share/mochi/plugins/.nix/. Building with Nix has the details.
This covers most plugins, not all of them. Mochi guesses the build from the plugin’s files, and a plugin that does more than its language’s usual build can fail, like one that generates code, links a library its manifest doesn’t name, or downloads things while building. Go without vendor/, Java, and other languages without a lock file Nix can read aren’t built at all, since Nix would need a hash for their downloads. For those, use the plugin’s releases:
- With
mochi plugins install: agit-release:source. A usual Linux binary looks for its loader in/lib64, which NixOS doesn’t have, so it runs only if the binary is static orprograms.nix-ldis on. Rust plugins released with Mochi’s release workflow are static. - With home-manager: the release archive as
src, as a flake input likeurl = "https://github.com/User/repo/releases/download/v1.0/plugin-1.0-x86_64-linux.tar.gz"; flake = false;. Mochi patches its binaries to run on NixOS, andflake.lockpins the archive, with no hash to write.
If a plugin has no releases and doesn’t build, ask its author for releases or a flake.nix.
Installing
mochi plugins install # every plugin in plugins.toml that isn't installed
mochi plugins install pomodoro # just this one
Before anything runs, install shows what the plugin is and what it will do, and asks:
Pomodoro 0.1.0 (pomodoro)
A focus timer: a bubble counts down, the island says when to rest
from git:github.com/User/mochi-pomodoro:main at 4f1c2a9d0e
runs cargo build --release --locked --target-dir target && install -Dm755 target/release/pomodoro bin/pomodoro
in /home/you/.local/share/mochi/plugins/pomodoro
starts bin/pomodoro with mochid
reads the state of media
actions start, break, pause, stop, status
Install pomodoro? [y/N]
--yes skips the question. Installed plugins live in ~/.local/share/mochi/plugins/<id>/, and a running mochid reloads to pick them up.
Then enable the plugin like a builtin module, in config.toml:
modules = ["idle", "osd", "media", "control-center", "pomodoro"]
[module.pomodoro]
focus_minutes = 50
A plugin’s settings go in its [module.<id>] section, like a builtin’s. The plugin’s settings.toml lists them.
When a build fails
install names the tools missing and the ways around it that apply to the plugin:
mochi: chrono: the build failed (exit status: 127): cargo build --release ...
`cargo` isn't installed. Ways around it:
- install it, then run `mochi plugins install chrono` again
- with home-manager, let Nix build it during the switch, with no tools here:
programs.mochi.plugins.chrono.src = <a flake input of its repository>;
- use its prebuilt releases, if it publishes them:
chrono = { source = "git-release:github.com/Someone/mochi-clock" }
- install Nix: with it, Mochi builds plugins from their lock files, with no other tools
Pinning and updating
install records what each plugin resolved to in plugins.lock, next to plugins.toml: the commit for git:, the tag and the asset’s hash for git-release:, the URL and its SHA-256 for an archive. From then on, install installs exactly that, on this machine or another one with the same files, until you update:
mochi plugins update # fetch every plugin's branch or latest release again
mochi plugins update pomodoro
A release asset that changed since the lock recorded it is refused. update leaves an archive as it is, since its hash pins it: give another URL and hash to install another one. Changing a plugin’s source in plugins.toml makes the next install resolve it again.
Checking and removing
mochi plugins list
mochi status
list shows each plugin’s source, what it’s pinned at, its version, and whether it runs. A plugin is running, disabled when it’s installed but not in modules, missing when it isn’t installed or its manifest has an error, or failed. A plugin’s backend that crashes starts again after a moment; after 5 crashes within a minute it stays stopped until mochi reload, and a notification says so.
mochi plugins remove pomodoro
deletes the installed files and the lock entry. Remove the plugin from plugins.toml too, or the next install brings it back.
A plugin’s id can’t be a builtin module’s, and two plugins can’t share an id. A plugin listed in plugins.toml counts as a module in config.toml even before it’s installed, so the file stays valid on a new machine; it just doesn’t run until it’s installed.
With home-manager
programs.mochi.plugins writes plugins.toml, so config.toml can enable plugins and still pass the build-time check:
programs.mochi = {
enable = true;
plugins.pomodoro = "git:github.com/User/mochi-pomodoro:main";
settings.modules = [ "idle" "osd" "media" "control-center" "pomodoro" ];
};
With a string, installing stays your step: run mochi plugins install after switching.
Nix can build the plugin during the switch instead, so the machine needs no build tools and there’s no install step. Add the plugin’s repository as a flake input and give it as src:
# flake.nix
inputs.mochi-pomodoro = {
url = "github:User/mochi-pomodoro";
flake = false;
};
# home-manager
programs.mochi.plugins.pomodoro = {
src = inputs.mochi-pomodoro;
# Native libraries its backend links, if any.
buildInputs = [ pkgs.alsa-lib ];
};
This works for the languages in On NixOS, and with Nix, and needs no hash. For a plugin it can’t build, give its release archive as src instead. Programs the backend runs come from the manifest’s needs; runtimeInputs = [ pkgs.ffmpeg ]; adds others, and buildInputs native libraries it links. plugins.toml then points at the build in the Nix store, and nix flake update mochi-pomodoro moves it to the latest commit. A plugin with its own flake can be given as package instead: programs.mochi.plugins.pomodoro.package = inputs.mochi-pomodoro.packages.${pkgs.system}.default;.
Bento
Bento shares setups, themes and plugins. A bento is a whole setup in one directory: the settings, the theme, the widgets and the plugins they need. You make one from what you run with one command, push it to a git repository, and anyone installs it with another.
mochi bento search clock # look through the registry
mochi bento add pomodoro # install from it
mochi bento share ~/cozy # make a bento of your setup
mochi bento add github.com/someone/cozy # install one from anywhere
mochi bento try github.com/someone/dusk # try a theme or a bento, then Keep or Drop
mochi bento use cozy # switch to an installed bento, or a theme
mochi bento use mine # back to your own setup
mochi bento remove cozy # take it out again
mochi bento list # what Bento installed
mochi bento update # move to newer releases
add, try and remove work for all three kinds: a directory with a mochi-bento.toml is a bento, one with a mochi-theme.toml a theme, and one with a mochi-plugin.toml a plugin. Themes and bentos hold only TOML and images, so they run nothing; a plugin is code, and asks before it installs, as mochi plugins install does.
Turning it on
Bento is off until you turn it on. What it installs comes from other people. Themes and bentos are settings, so the most they can do is change how your desktop looks and behaves, and you can switch back to your own setup. Plugins are programs: once installed, a plugin runs with the same rights as you, so it could read your files or send them somewhere, and a bento can bring plugins with it. Someone reads each plugin’s code before the registry lists it, and the themes and bentos there are checked automatically, which stops a lot but not everything; nothing installed from a link or a repository is checked at all.
The settings’ Bento page explains this and has a button to turn it on, or set this in config.toml:
[bento]
i_really_understand_that_bento_can_harm_and_contain_malicious_content = true
While it’s off, add, try, plan, search, info and update refuse and say why, and nothing is downloaded. The switch at the top of the Bento pages turns it off again, and on. What’s installed stays until you remove it: list, remove, use mine and themes keep working, and so do share, check and publish, which only read your own files.
The switch belongs to no setup: switching between bentos leaves it as it is.
In the settings
The settings panel has a Bento group at the bottom of its sidebar, with three pages. mochi ipc settings open bento opens it.
While Bento is off, Discover says what Bento installs and what can go wrong, with a button to turn it on: see Turning it on.
- Discover lists the registry: a card per package, with its first screenshot, a search, and filters for plugins, widgets (plugins tagged
widget), themes and bentos. A card opens the package’s page: its screenshots, who looks after it, its license and repository, then Install and, for themes and bentos, Try. Under the cards, a field takes anything elseaddtakes, like a repository or a gist. - Install first shows what it will do, the same as the terminal’s question: what a plugin builds, starts, runs and reads; a theme’s colors; a bento’s settings, themes, widgets and wallpaper, and the plugins it needs with what each runs. Nothing happens until you press Install again. A bento whose settings don’t check, or that needs a plugin that can’t be installed, can’t be installed.
- Installed lists your own setup and each bento, with Use to switch to one, then the themes, with Use to put one on, and the plugins. It has Update where the registry has a newer release, Update all, and Remove, which asks once more. What a bento brought follows its bento. A release the registry withdrew says so in red.
- Share makes a bento of this setup, with the parts you pick, or your look as a theme, in a directory you name, and lists what it wrote and what it left out.
The panel runs mochid bento for each of these, so it does exactly what the terminal does, and stays usable while a plugin builds.
Links
mochi://bento/<id> links open the Discover page on what installing that package does, so a web page can offer an Install button. The id can be anything add takes, with its / written %2F: mochi://bento/github.com%2Fsomeone%2Fcozy. A link never installs anything by itself.
The Nix and Arch packages install mochi-links.desktop, which hands mochi:// links to mochi open-url. If your browser doesn’t offer it, make it the handler:
xdg-mime default mochi-links.desktop x-scheme-handler/mochi
or with home-manager, xdg.mimeApps.defaultApplications."x-scheme-handler/mochi" = "mochi-links.desktop";.
Where from
add and try take:
| Given | Means |
|---|---|
pomodoro, bento:pomodoro, bento:pomodoro:0.3.0 | A package in the registry: the newest release this Mochi runs, or the one named. |
~/cozy, ./cozy, path:~/cozy | A directory, used where it is. |
github.com/<user>/<repo>, gh:<user>/<repo> | A GitHub repository, cloned at its default branch. |
https://gist.github.com/<user>/<id> | A gist, which is a git repository too: one with only a mochi-bento.toml is a whole bento. |
git:<url>:<ref>, git-release:… | A source as plugins.toml takes it, with a branch, a tag or a commit. |
https://<url>#sha256=<hash> | A plugin’s archive, as plugins.toml takes it: downloaded, checked against its hash and unpacked. |
bento:friends/pomodoro | A package in another registry, see Other registries. |
A repository is cloned to a scratch directory and read before anything happens; cloning runs none of its code.
Making one
mochi bento share ~/cozy --name "Cozy"
share writes ~/cozy/mochi-bento.toml from the setup running now: what your files and the settings panel set that isn’t a default, the theme, the widgets and the plugins they use. The directory’s name is the bento’s id. A theme you installed goes along in themes/<id>/, and --wallpaper brings the wallpaper awww, swww or hyprpaper shows. --print prints the manifest instead, to paste into a gist.
To share only some of it, name the parts with --only:
mochi bento share ~/night --only theme,module:nightlight,widgets
The parts are theme; shell, the island and the bubbles; modules, which modules run, with the plugins they need; settings, every module’s settings, or module:<id> for one module’s; widgets; and wallpaper. Without --only, a bento brings every part but the wallpaper. mochi bento parts says which parts your setup has. Whether Bento is on never goes in.
--theme writes your look as a theme instead, a mochi-theme.toml: the colors of the preset in use with yours over them, in both versions, and the fonts, shape and motion you set. Others install it like any theme.
The settings’ Share page does the same: A bento with a switch for each part, each module’s settings on its own, or A theme.
It leaves out what belongs to your machine or to you, and lists each thing it left out:
- Options whose values are this machine’s devices, like a recording’s audio output.
- Where you are, like night light’s
latitudeandlongitudeor the weather’splace, and keys that hold secrets, liketoken,passwordorapi_key. - Paths in your home directory. A path written with
~/stays, since it works on any machine. - Values that look like tokens: long runs of letters and digits.
- Plugins in a local directory (
path:), which nobody else can install, and the widgets they offer. - Widgets on a screen that isn’t connected.
Read the list, add a description and screenshots to the manifest, then push the directory to a git repository.
Installing one
$ mochi bento add github.com/someone/cozy
Fetching git:github.com/someone/cozy…
Cozy 1.0.0 (cozy)
Warm colors, a clock and notes on the big screen
by someone
from git:github.com/someone/cozy at d34ba43578
settings 12 options, 2 of the theme
themes 1 brought along
plugins pomodoro
widgets 3 on 2 screens
needs pomodoro from git:github.com/someone/mochi-pomodoro, which asks before it installs
It's a setup you switch to: its settings go over yours, its widgets replace yours, and
`mochi bento use mine` switches back to your own, as you left it.
Add cozy? [y/N]
Before installing anything, add checks the bento’s settings the way mochi config check would, so a typo or an option this Mochi doesn’t know changes nothing. Then it installs the themes it brings and the plugins it needs, each plugin showing what it runs and asking. Then it switches to the bento, unless you add --no-use. If any step fails, what it installed is removed and nothing changes.
Adding a theme puts it on in the same way, as preset; --no-use only installs it.
Switching setups
Your own setup and each bento you installed are setups to switch between: mochi bento use cozy, mochi bento use mine, or Use on the Installed page. Each keeps its own changes.toml and widgets.toml, so what you change while using a bento stays with that bento, and your own setup comes back as you left it. A bento used for the first time starts from your own setup, with its settings over yours, like changes from the settings panel: a dot marks each one there, Copy hands them to your Nix or TOML config, and they work while home-manager owns your files. Its widgets replace yours, and its wallpaper is set with awww or swww when one runs; going back to your own setup sets your wallpaper again.
The plugins a bento needs run while it’s in use, since its list of modules is the one in place. mochi bento use <theme> puts a theme on in whichever setup is in use.
mochi bento remove cozy switches back to your own setup first when cozy is in use, forgets what its setup became, and removes the themes and plugins it brought that no other bento needs. Adding a bento again updates it: the one in use gets its new settings over the ones in place, and another starts fresh the next time you use it. Setups are kept in ~/.local/share/mochi/bentos/.
--yes skips the questions, plugins’ included.
Trying
mochi bento try applies a theme, or a bento’s settings and theme, without keeping them, through the settings panel’s preview. It opens the panel, whose bar at the bottom has Keep, which makes them changes like any other, and Drop, which goes back; mochi ipc settings keep and drop do the same, and a reload drops them too. It needs the settings module running. A bento’s widgets, wallpaper and plugins only come with add; try leaves out the modules whose plugins aren’t installed, and says which. The themes it needs stay installed after a Drop, and mochi bento remove <theme> takes one out.
The registry
Bento’s registry lists plugins, themes and bentos whose releases someone checked. Each release is pinned to a commit: installing clones the package’s own repository at that commit, the code a reviewer read, never a branch that moved since. A person reads the code of every plugin release before it’s listed; themes and bentos, which run nothing, are listed once checks pass.
$ mochi bento search purple
dusk theme 0.2.0 Purple evening
$ mochi bento info dusk
Dusk (dusk), a theme
Purple evening
by someone, MIT
repository https://github.com/someone/mochi-dusk
0.3.0 1c522779b3 needs Mochi 0.0.9
0.2.0 6c2755f1dc what `add` installs
Install it with `mochi bento add dusk`.
add installs the newest release that the running Mochi supports, so an older Mochi still gets something that works. A name alone means the registry, unless a directory by that name is where you run it. Plugins from the registry are recorded as bento:<id> sources, so mochi plugins install on another machine installs the same release, and plugins.lock keeps its commit.
mochi bento update moves what Bento installed to newer releases: plugins to the newest the registry lists, and themes and bentos from a repository to its newest commit. A bento asks again before laying its settings over yours. With ids, it updates only those; a directory is updated only when named.
Mochi downloads the registry’s index.json when it needs it and keeps it in ~/.cache/mochi/bento/ for ten minutes, or longer when the registry can’t be reached.
Withdrawn releases
The registry can withdraw a release. A yanked one is no longer installed, and mochi bento list and mochid’s log say so where it is. One withdrawn as harmful is refused, and mochid doesn’t start it: mochi status names it and says to remove it. mochid only reads the index Mochi last downloaded, so a search, an install or an update brings the news.
Other registries
[registries] in bento.toml adds registries, by name, with their index’s URL:
[registries]
friends = "https://friends.example/index.json"
mochi bento add bento:friends/pomodoro installs from it. A bento entry points the default registry elsewhere. Anyone can run one: the registry’s repository is a template in Mochi’s source, in examples/bento-registry, with its checks.
Publishing
The registry is a git repository with a file per package, packages/<id>.toml, naming its repository, its maintainers, its license and each release’s version, commit and oldest Mochi. A pull request adds one, or a release to one. Its README says what’s checked and who merges.
mochi bento publish sends one for you. Run it in your package’s repository, with the release committed, tagged and pushed:
git tag v1.0.0 && git push --tags
mochi bento publish --tag dark --tag purple
It checks the release as the registry’s CI will, from your manifest and LICENSE file, writes the package’s file or adds the release to the one there, shows it, and with your yes opens the pull request from a fork of the registry, with gh. A plugin’s manifest doesn’t say which Mochi it needs, so give it with --mochi 0.0.8; it’s the running Mochi otherwise. --print only prints the file, to send by hand, and --registry owner/name sends it to another registry.
To send each release as you tag it, copy examples/bento-publish.yml from Mochi’s source into your repository’s .github/workflows/, with a BENTO_TOKEN secret that can open pull requests.
mochid bento registry check, index and diff are the tools the registry’s CI runs, and mochi bento check runs the same checks on your package before you send it.
bento.toml
What Bento installed is in bento.toml, next to config.toml. Bento writes it, never home-manager, so installing works while home-manager owns your config:
[plugins.pomodoro]
source = "git:github.com/someone/mochi-pomodoro"
version = "0.3.0"
by = "cozy"
[themes.mint]
source = "git:github.com/someone/cozy"
revision = "d34ba435786f27e4d50f7ac6feaf488914513d77"
version = "1.0.0"
by = "cozy"
[bentos.cozy]
source = "git:github.com/someone/cozy"
revision = "d34ba435786f27e4d50f7ac6feaf488914513d77"
version = "1.0.0"
[registries]
friends = "https://friends.example/index.json"
Its plugins count as if plugins.toml listed them: mochi plugins install installs them on a new machine, mochi plugins list shows them, and plugins.toml wins when both list an id. by names the bento that brought something, which removing the bento removes too. The settings panel’s Copy as Nix includes its plugins as plugins, for programs.mochi.plugins. Themes go in ~/.local/share/mochi/themes/, and the bentos with their setups in ~/.local/share/mochi/bentos/<id>/, yours in .mine/. active names the bento in use, when one is.
[registries] is the one part you edit yourself: see Other registries.
mochi-bento.toml
[bento]
id = "cozy"
name = "Cozy"
version = "1.0.0"
mochi = "0.0.8"
description = "Warm colors, a clock and notes on the big screen"
authors = ["someone"]
homepage = "https://github.com/someone/cozy"
screenshots = ["screens/desk.png"]
wallpaper = "wallpaper.jpg"
[plugins]
pomodoro = "git:github.com/someone/mochi-pomodoro"
[config]
modules = ["idle", "osd", "control-center", "widgets", "notes", "pomodoro"]
[config.module.osd]
timeout_ms = 2500
[theme]
preset = "mint"
appearance = "auto"
[[widget]]
id = "w1"
module = "widgets"
widget = "clock"
output = "screen-1"
anchor = "top-right"
x = -2
y = 3
width = 14
height = 7
[bento] says what it is. id is lowercase letters, digits, - and _, starting with a letter. mochi is the oldest Mochi it works with: an older one refuses it and says why. screenshots and wallpaper are paths inside the bento.
[plugins] lists the plugins it needs, by id, with a source as plugins.toml takes it, like bento:pomodoro for one in the registry. A path: source can’t be shared, so it isn’t allowed.
[config] goes over config.toml and [theme] over theme.toml, with the same keys. Tables merge key by key, and anything else replaces what was there, so modules is the whole list. preset can name a theme the bento brings in themes/<id>/mochi-theme.toml.
[[widget]] is a widget as widgets.toml places it, except output: screen-1 is the largest screen, screen-2 the next, and so on, so widgets land on the same kind of screen whatever the outputs are called. A widget for a screen the machine doesn’t have keeps screen-2 or the like as its output, which matches no monitor, so it stays hidden until you set output to a monitor’s name in widgets.toml.
mochi bento check <dir> reads a bento, a theme or a plugin as add would, without installing anything.
Profiling
When Mochi feels slow, uses a lot of CPU, or a game stutters while it runs, Mochi can say what it costs, and where.
A report to send
mochi profile # 30 seconds
mochi profile 60 # up to 300
While it records, use the computer as when the problem shows: play the game, play music, open what’s slow. Then it prints the path of a report, one HTML file in ~/.local/state/mochi/profiles. Open it in a browser, or attach it to a bug report. It works in every build, the released ones too.
The report has:
- CPU over time, every half second, for mochid, Quickshell and the programs they start, like
nvidia-smiorcurl, in percent of one core: 100% is one core busy. - Frames drawn: how many frames each of the shell’s windows drew each second, the island and the desktop of each monitor. Idle, it’s close to 0. Something that moves draws up to the monitor’s refresh rate, 144 times a second on a 144 Hz monitor, which is what costs on a gaming setup.
- Wake-ups: how often each process woke up. Many wake-ups with little CPU still keep a core from resting.
- mochid’s flame graph: where mochid’s own time went, function by function. Click a box to zoom in.
- The busiest threads, each module’s time in its own task, memory, and the machine: Mochi’s version, the compositor, the monitors, the CPU and the kernel.
Quickshell’s QML has no flame graph: that needs a Quickshell built with Qt’s QML profiler. Its threads, frames and wake-ups usually tell enough: a window drawing every frame while nothing should move points at an animation.
Live, in dev mode
mochid --dev, which cargo run -p mochid starts, shows a bubble with its revision. Click it for the profiler: what mochid, Quickshell and the helpers cost now, the last minute of CPU, the frames each window draws, and the busiest threads and modules, twice a second. Record 30 s writes the same report as mochi profile, and Open the report opens it. Close, or a click on the bubble, stops it.
What it costs
Nothing until something asks. While the panel is open or a recording runs, a thread reads the process tree from /proc twice a second, the shell counts the frames each window draws, and a recording samples mochid’s stacks 199 times a second for the flame graph. Each module’s time in its own task is counted all the time, which takes two clock reads each time the task runs. The panel and the report show the profiler’s own thread, mochi-profile, with the rest.
A recording leaves about 60 MB in mochid until it restarts: the stack sampler keeps a table of samples ready for the next one, whatever its size. Naming the functions for the flame graph takes more for a moment, which mochid hands back once the report is written.
The flame graph needs mochid’s function names. The release archives and the Nix and Arch packages keep them, and leave out the rest of the debug information.
Idle
The clock the island shows when nothing else is happening. Clicking it opens the control center; click = ["clock", "toggle"] opens the clock panel instead.
Resting the pointer on it can run another action, hover. For the workspace dots, to click or scroll through:
[module.idle]
hover = ["workspaces", "show"]
hover waits for the pointer to rest on the clock for hover_delay_ms, so passing over it does nothing and a quick click still runs click. Whatever it shows stays while the pointer is on the island, and goes about a second after the pointer leaves.
# Idle: the clock shown when nothing else is.
[module.idle]
# How the clock shows the time.
# format = "HH:mm"
# What a click on the clock does. None does nothing.
# click = ["control-center", "toggle"]
# What resting the pointer on it does, like showing the workspace dots.
# None does nothing.
# hover = []
# How long the pointer rests on it before that happens, in milliseconds,
# so passing over it or clicking it doesn't.
# hover_delay_ms = 350
OSD
Shows changes as they happen, from any source: the output volume and mute, a switch of the output device, the microphone’s mute, Caps Lock, Num Lock and the keyboard layout. It listens only and has no actions. The audio notices need PipeWire with its PulseAudio server, or PulseAudio.
Keyboard layout
When the keyboard layout switches, the OSD shows the new layout’s name, like “German”. No Wayland protocol says the layout, so Mochi asks the compositor’s IPC: Hyprland, niri and Sway tell it, and other compositors show nothing. At startup Mochi takes Hyprland’s main keyboard, or on Sway the first keyboard with a named layout, then follows whichever keyboard switches. Keymaps without a name, like the ones apps such as wtype make to type, are skipped.
The OSD module also publishes the current layout for other views: Daemon.state("osd").keyboard_layout is the layout’s name, or null while the compositor hasn’t said. It’s there with layout = false too, which only turns the notice off. mochi status shows it on the compositor line.
# OSD: shows volume, mute, the output device, microphone mute, Caps Lock,
# Num Lock and the keyboard layout as they change, from any source. Needs
# PipeWire or PulseAudio.
[module.osd]
# How long a notice stays, in milliseconds.
# timeout_ms = 1500
# Each kind of notice can be turned off.
# volume = true
# device = true
# microphone = true
# locks = true
# layout = true
Workspaces
Shows a monitor’s workspaces as dots, with the active one stretched into a pill, when you switch, when focus moves to another monitor, when a workspace asks for attention, or when one is created or removed. Click a dot to switch to it, or scroll on the dots for the previous or next one.
mochi ipc workspaces show shows the dots on demand, for the monitor under the pointer or the one named, and keeps them while the pointer is on them. The idle module’s hover = ["workspaces", "show"] shows them when the pointer rests on the clock.
It works on any compositor with the ext-workspace-v1 protocol.
# Workspaces: shows a monitor's workspaces when you switch, when focus moves
# to it, when one asks for attention, or when they're created or removed.
# Click a dot to switch, or scroll on them. `mochi ipc workspaces show`
# brings them up when you want, like from the idle module's `hover`.
[module.workspaces]
# How long the indicator stays, in milliseconds.
# timeout_ms = 1200
# Show a monitor when focus moves to it.
# focus = true
# Show workspaces that ask for attention.
# urgent = true
# Show workspaces being created or removed.
# changes = true
# Names for the monitors, shown when two or more are connected; without one
# the connector's name, like DP-3, shows.
# labels = {}
| Action | What it does |
|---|---|
mochi ipc workspaces switch <monitor> <workspace> | Switches a monitor to one of its workspaces |
Media
Shows what’s playing in any player that speaks MPRIS: Spotify, browsers, VLC, mpv with mpv-mpris, and most others. A new track takes the island with the cover, the progress and the controls; after a few seconds the music becomes a bubble with the cover and a progress ring. Click the bubble to bring the player back, and click or drag the progress line to seek. Once you click the player open, Escape or a click outside sends it back to its bubble.
Players that report a volume of their own, like Spotify, get a volume slider under the controls on the island, and next to the controls on the control center card when it has room. That volume is the player’s, apart from the app’s volume in the mixer: it’s the one the player’s own slider shows. Players without one, or that take no commands, get no slider. Double-click it to put it back to 100%.
When several players are open, the one that last started playing wins, and a playing one always beats a paused one. Arrows next to the player’s name, on the island and on the control center card, switch to another player that has a track. The one you pick stays shown until it stops or closes, even when another starts a new track; then the rule above applies again.
The progress line waves while a track plays and lies flat when it pauses. wavy = false keeps it flat, and the theme’s waves = false in [motion] keeps every wave in Mochi flat, whatever the modules say: see Motion. line_color = "accent" draws the line in the accent instead of the text’s color. On the control center card and the desktop card the line only shows the progress; card_seeks = true makes it seek there too, where the player can.
# Media: what's playing in any MPRIS player. A new track shows on the island,
# then the music becomes a bubble next to it.
[module.media]
# How long a new track shows the full player, in milliseconds.
# expand_ms = 4000
# Then how long the compact view stays before the music becomes a bubble.
# island_ms = 3000
# How long a paused player's bubble stays.
# paused_ms = 3000
# Players never shown.
# ignore = []
# The progress line waves while a track plays. Off keeps it flat. The theme's
# waves, under Motion, can keep every wave flat whatever this says.
# wavy = true
# The progress line's color: "foreground", like the text, or "accent".
# line_color = "foreground"
# The now playing card's line seeks on a click or a drag, in the control
# center and on the desktop, as the island's player does.
# card_seeks = false
| Action | What it does |
|---|---|
play-pause, play, pause | Controls playback |
next, previous | Changes track |
seek <seconds> | Jumps to a position in the track |
volume <level> | Sets the shown player’s own volume: 40 sets it, +5 and -5 move it, up to 100 |
next-player, previous-player | Shows another player, until it stops |
player <name> | Shows the player with this name, like spotify or firefox, until it stops |
It offers the control center a Now Playing card, and the desktop a widget in three looks: the same card; artwork, a tall card with the cover big and the track, the progress and the controls under it; and cover, only the cover, without a card, with a button to play or pause in its corner.
Audio
A volume mixer, like pavucontrol’s: the output and the input with their volumes, and a slider and a mute for each app playing sound and each app recording. It shows as the control center’s Sound page, and mochi ipc audio toggle, bound to a key, opens the same mixer on the island; Escape or a click outside closes it. It needs PipeWire with its PulseAudio server, or PulseAudio.
Click the output’s or the input’s name to list the other devices, and click one to switch to it. Click an icon to mute or unmute. Apps playing come first; paused ones are dimmed. An app’s icon is the one the launcher shows for it: Mochi finds the app’s desktop entry by what its stream says, its Flatpak id, app id, icon, program or name, so Zen, Chromium and a Discord call get their icons even when the stream names one the icon theme lacks, or none. Streams without a volume of their own, like some system sounds, aren’t listed.
The streams of one app share a row, so two browser tabs playing get one Firefox row. Its slider sets every stream to the same level, and its icon mutes them all; the row shows the loudest stream’s volume, and shows muted only when all of them are. When an app has more than one stream, click its name to open the row and see each stream with its own slider, mute and output.
While an app records from a microphone, like Discord in a call or OBS, a Recording section under the apps lists it, one row per app with its own volume and mute, and its streams inside like an app playing. That volume is what the app hears, apart from the input’s volume, which every app recording hears. Paused recordings are dimmed. The section leaves when no app records.
With more than one output, the button at the end of an app’s row lists the outputs, with the one the app plays through marked, and a click moves every stream of the app there. In an opened row, each stream’s button moves only that stream. PipeWire remembers where you moved an app: its next stream plays through the same output, without Mochi doing anything. mochi ipc audio move firefox headphones does the same from a keybind.
While the mixer shows, on the island or as the control center’s Sound page, every slider has a meter: the fill dims, and the part of it the sound reaches stays lit. A meter is on the volume’s scale, so it never goes past the slider’s end: a full-scale sound fills the whole volume, a quiet one a little of it. An app’s row shows its loudest stream. An app recording has no meter of its own: its row shows the input’s meter at the app’s volume, while it records from the input in use. The output’s meter moves only while something plays, and the input’s only while an app records from it, so opening the mixer never wakes the microphone. The meters cost nothing while no mixer shows: Mochi asks the audio server for peak levels only while one is open, and the server sends 25 a second for each slider instead of the sound itself.
# Audio: the volume mixer, as the control center's Sound page.
# `mochi ipc audio toggle` opens it on the island.
[module.audio]
# The loudest the sliders, the volume keys and the OSD's bar go, in percent, up to
# 300: 200 lets you boost a quiet video to twice the device's normal level.
# Past 100 the sound is amplified in software and may distort, and the
# sliders mark where 100 is.
# max_volume = 100
| Action | What it does |
|---|---|
toggle, open, close | Opens or closes the mixer on the island |
volume <target> <level> | Sets a volume: 40 sets it, +5 and -5 move it, never past max_volume |
mute <target> [on|off|toggle] | Mutes or unmutes; toggle when left out |
output <name> | Plays sound through another output |
input <name> | Records from another input |
move <app> <device> | Plays every stream of an app, or one stream by its id, through another output: its name, its description like Headphones, or output for the one in use |
meters <view> on|off | Runs the meters for 10 seconds, or stops them; the mixer sends this while it shows |
A target is output or input for the devices in use, a device’s name, an app’s name for all its streams, or a stream’s id. recording: before an app’s name or a stream’s id names what the app records instead of what it plays: mochi ipc audio mute recording:discord mutes Discord’s microphone and leaves the call’s sound alone. App names match ignoring case when no app has the exact name. pactl list short sinks, sources, sink-inputs and source-outputs list them. mochi ipc audio volume output +5 makes a volume key.
max_volume = 200 lets the sliders and volume go to 200%; the OSD’s volume bar then shows 200% as full, with a mark at 100%. Past 100%, the sliders and the bar turn to the accent color. Volume keys bound to mochi ipc audio volume output +5 stop at the same place; wpctl set-volume -l has its own limit.
Double-click a slider to put it back to 100%. A volume keeps each device’s balance: the loudest channel goes to the level and the others follow. While the mixer or another panel is open, the OSD’s volume notice doesn’t show, and doesn’t come back late once it closes. mochi ipc control-center open audio/mixer opens the control center on the Sound page.
Network
Wi-Fi, Ethernet, VPNs and airplane mode, from NetworkManager over D-Bus.
A bubble shows the connection: the Wi-Fi’s strength, Ethernet, or offline, with a small lock while a VPN runs. Click it to open the control center’s Network page. When you connect, disconnect, or a VPN starts or stops, the island shows a short notice.
The Network page has the Wi-Fi and airplane switches, the Wi-Fi networks in range with the one in use first, the wired devices and the VPNs. Click a network to join it. A saved one connects at once; a new secured one asks for its password on the island, and Enter joins. If the network doesn’t come up within 30 seconds, Mochi forgets it, so a wrong password isn’t kept, and says so. The trash button forgets a saved network. A network that asks for a user name, WPA Enterprise like eduroam, asks for it with the password and joins with PEAP and MSCHAPv2, what most of them use; one that needs another method or a certificate still needs setting up once with nmcli or nm-connection-editor. Hidden… next to Scan joins a network that doesn’t say its name: type it, pick Open, Password or Enterprise, and what that asks.
Mochi is NetworkManager’s secret agent too. When a connection needs a password NetworkManager doesn’t have, like a saved network whose password changed or a connection started with nmcli, it asks on the island, saying when the last one didn’t work. Cancel tells NetworkManager so. It answers for Wi-Fi passwords and 802.1X passwords; a VPN’s secrets go to another agent, like the VPN plugin’s own.
The home card has tiles for Wi-Fi (Ethernet on machines without it), the VPN when you have one, and airplane mode. Airplane mode turns Wi-Fi, the mobile radio and Bluetooth off, and turns back on the ones that were on.
# Network: Wi-Fi, Ethernet, VPNs and airplane mode, from NetworkManager. The
# control center has a Network page and a card. A bubble shows the
# connection: the Wi-Fi's strength, Ethernet or offline, and a lock while a
# VPN runs; a click on it opens the Network page.
[module.network]
# A short notice on the island when you connect, disconnect, or a VPN
# starts or stops.
# notices = true
| Action | What it does |
|---|---|
wifi [on|off|toggle] | Turns Wi-Fi on or off |
airplane [on|off|toggle] | Turns every radio off, or back on |
scan | Looks for Wi-Fi networks |
connect <name> | Joins a Wi-Fi network or starts a saved connection; a new secured network asks for its password |
hidden | Asks on the island for a hidden network’s name and security, then joins it |
disconnect [name] | Leaves a network, stops a VPN, or disconnects a wired device by its interface; the Wi-Fi when left out |
forget <name> | Forgets a saved Wi-Fi network |
vpn <name> [on|off|toggle] | Starts or stops a VPN |
The prompt sends answer <json> itself, with the password and what else it asked; password <ssid> <password> joins a network in range from a script. Mochi never logs either.
Night light
Warmer screens in the evening. Mochi sets each output’s gamma itself through wlr-gamma-control-unstable-v1, which Hyprland, Sway and niri have, so no other program runs. Turn off other night lights, like wlsunset, gammastep or hyprsunset: a compositor gives one program each output’s gamma, and Mochi says so when it can’t have it. When mochid stops, even by crashing, the screens go back to normal.
It turns on by hand, from the control center’s tile or mochi ipc nightlight toggle, or on a schedule: between two times of day, or from sunset to sunrise where you are, worked out from your latitude and longitude. A schedule warms up and cools down over fade_minutes. Turning it on or off by hand slides there in under a second, and lasts until the schedule changes next; auto hands it back to the schedule at once.
# Night light: warmer screens in the evening, through the compositor's
# gamma control. Turn off other night lights, like wlsunset or hyprsunset.
[module.nightlight]
# How warm, in kelvin, from 1000 to 6000. Daylight is 6500.
# temperature = 4000
# When it turns on by itself: Manual only by hand, Times between the start
# and the end below, or Sun from sunset to sunrise where you are.
# schedule = "manual"
# When night starts, with the times schedule.
# start = "20:00"
# When night ends, with the times schedule.
# end = "07:00"
# Where you are, for the Sun schedule: north and east are positive.
# latitude = 0.0
# longitude = 0.0
# How long a schedule takes to warm up or cool down, in minutes.
# fade_minutes = 30
For sunset to sunrise in Paris:
[module.nightlight]
schedule = "sun"
latitude = 48.85
longitude = 2.35
| Action | What it does |
|---|---|
on, off, toggle | Warm or daylight until the schedule changes next |
auto | Follows the schedule again |
temperature <kelvin> | The night’s temperature until mochid restarts, from 1000 to 6000 |
status | Prints whether it’s on, how warm, and any problem |
Bluetooth
Power, paired devices with their battery, scanning and pairing, from BlueZ over D-Bus.
While a device is connected, a bubble shows the Bluetooth symbol and the device’s battery when it reports one, red at 15% or less. Click it to open the control center’s Bluetooth page. When a paired device connects or disconnects, the island shows a short notice, like “Buds connected · 70%”.
The Bluetooth page has the power switch, the paired devices, connected first, to connect, disconnect or forget, and the devices in range to pair. Scan looks for 30 seconds. Pairing trusts the device, so it can connect by itself later, and connects it. The home card is a tile that turns Bluetooth on and off.
Mochi is BlueZ’s pairing agent, so pairing asks on the island: whether the code a phone shows matches, whether a device without a code may pair, the PIN an older device expects, or a code to type on a keyboard. Escape or a click outside says no.
# Bluetooth: power, paired devices with their battery, scanning and pairing,
# from BlueZ. The control center has a Bluetooth page and a tile, and a
# bubble shows a connected device with its battery; a click on it opens the
# Bluetooth page.
[module.bluetooth]
# A short notice on the island when a paired device connects or disconnects.
# notices = true
# How long a scan looks for devices to pair, in seconds.
# scan_seconds = 30
| Action | What it does |
|---|---|
power [on|off|toggle] | Turns Bluetooth on or off |
powered | Succeeds when Bluetooth is on, for scripts |
scan [on|off|toggle] | Looks for devices to pair |
connect <device>, disconnect <device> | By name or address |
pair <device> | Pairs a device in range, trusts it and connects it |
forget <device> | Forgets a paired device |
The pairing questions send answer yes|no and pin <code> themselves.
Without an adapter, or with BlueZ stopped, the page and the tile say so, and the module waits for BlueZ to start.
Battery
A laptop’s batteries, and the batteries of mice, keyboards, controllers, headsets and other devices, from UPower over D-Bus. Without any of them, as on a desktop without wireless devices, it shows nothing.
On battery, dropping past a level shows a short notice on the island, like “Battery at 50% · 2 h 20 min left”, once per discharge: at 80, 50, 20 and 10% by default. At or under the warning level, 50% by default, a bubble with the level stays next to the island until you plug in. At the critical level, 10% by default, the bubble turns red and breathes, and the notice turns red and stays ten seconds, even over an open panel. Plugging the charger in or out shows a notice too, with the time left on battery.
The control center has a card with the level and the time until empty or full. Under it, a line for each battery of a laptop with two, and one for each device that reports its battery to UPower, with its name and level, red when low. When a device drops to 15%, the island says so once, like “MX Master 3 battery low · 15%”, and again only after it charges. A device already low when Mochi starts says nothing; one that connects already low does. Clicking the bubble opens the control center.
# Battery: a laptop's batteries, and the mice, keyboards and controllers that
# report theirs, from UPower. Nothing shows without any.
[module.battery]
# Levels, in percent, that show a short notice on the island when the
# battery drops past them while unplugged. Each shows once per discharge.
# notices = [80, 50, 20, 10]
# At or under this, unplugged, a bubble with the level stays next to the
# island.
# warning = 50
# At or under this, the bubble and the notice turn red, and the notice stays
# for ten seconds, even over an open panel.
# critical = 10
# A notice when the charger is plugged in or out.
# plugged = true
# A notice when a mouse, keyboard, controller or another peripheral drops to
# this level, once until it charges. 0 turns it off.
# peripherals = 15
# The ring look waves while the battery charges. Off keeps it flat. The
# theme's waves, under Motion, can keep every wave flat whatever this says.
# wavy = true
notices = [] turns the level notices off, warning = 0 the bubble, and peripherals = 0 the devices’ notices. The levels count the combined charge of every battery, as UPower’s display device reports it.
mochi ipc battery status prints each battery and device with its level.
On the desktop, the card is a widget too, and so is a ring: the level as a ring with the percent inside, and under it “Charging”, “Fully charged”, “Plugged in” or “On battery”, with how long until full or empty when UPower knows. The ring waves while the battery charges, and turns red when it’s low. wavy = false keeps it flat, as does the theme’s waves = false in [motion].
Bluetooth devices
UPower lists Bluetooth devices that report a battery too, so a Bluetooth mouse shows on this card and on the Bluetooth page. The card is the one list of every battery; the Bluetooth page shows the level next to the device you connect or forget. Only this module says when a battery gets low, so a device gets one notice. When UPower finds one device twice, through the kernel and through BlueZ, the card lists it once.
Brightness
The laptop’s backlight, the keyboard’s backlight, and external monitors over DDC/CI. Without any of them, it shows nothing.
The backlight comes from /sys/class/backlight, and the keyboard’s from the LED named like tpacpi::kbd_backlight in /sys/class/leds. Mochi changes both through logind, which lets the user of the active session set them without a udev rule, and writes the file itself when logind refuses. Mochi reads them twice a second, so a change made elsewhere, like a brightness key the firmware handles or Fn+Space on a ThinkPad, shows the OSD too.
Monitors come from ddcutil. It needs the i2c-dev kernel module and access to /dev/i2c-*, which the i2c group or ddcutil’s udev rule gives. On NixOS, hardware.i2c.enable = true does both and adds your user to the group once you list it in users.users.<name>.extraGroups. Finding the monitors takes a few seconds, so Mochi does it once at the start; mochi ipc brightness refresh looks again after you plug one in. While a slider moves, each monitor gets only the latest level, as DDC/CI is slow.
The control center has a card with a slider for each display and one for the keyboard. The OSD shows the level when it changes, and scrolling on it changes it.
# Brightness: the laptop's backlight, the keyboard's, and external monitors
# over DDC/CI.
[module.brightness]
# The percent each step of the brightness keys moves.
# step = 5
# Monitors over DDC/CI, through ddcutil. It needs the i2c-dev kernel module
# and access to /dev/i2c-*, from the i2c group or ddcutil's udev rule.
# external = true
# The level on the island when it changes, also from a key the firmware
# handles.
# osd = true
Keybinds
mochi ipc brightness up # every display, by the step
mochi ipc brightness down backlight # only the laptop's screen
mochi ipc brightness set 40 DP-1 # a monitor, by its output or model
mochi ipc brightness set +10 external
mochi ipc brightness up keyboard # the keyboard's backlight, a level up
mochi ipc brightness status
all, the default, means every display; the keyboard changes only when you name it. A keyboard often has two or three levels, so up and down move it at least one level, whatever the step.
On Hyprland:
bindel = , XF86MonBrightnessUp, exec, mochi ipc brightness up
bindel = , XF86MonBrightnessDown, exec, mochi ipc brightness down
bindel = , XF86KbdBrightnessUp, exec, mochi ipc brightness up keyboard
bindel = , XF86KbdBrightnessDown, exec, mochi ipc brightness down keyboard
mochi doctor says when ddcutil is missing.
Performance
CPU, memory and GPU use, the CPU’s and GPU’s temperatures, and disk and network speeds.
The control center has a Performance page: CPU, memory and GPU, each with its value, a detail line (threads and temperature, memory used of total, video memory and temperature) and a graph of the last two minutes. Under them, disk and network each show two speeds and draw both in one graph: read and write, download and upload. Speeds count in B/s, KB/s, MB/s or GB/s, and their graphs scale to the fastest moment of the two minutes. Then come swap, the GPU’s name, and the six busiest processes with their CPU, memory and disk use. The process list updates while the page is open.
A switch above the list orders it by CPU, memory or disk. Disk use is what a process read from and wrote to storage, per second, from /proc/<pid>/io. Linux lets you read that file only for your own processes, so other users’ processes show no disk use and sort last. When a program’s child process exits, Linux adds the child’s bytes to the program’s count, so a shell or terminal that ran a big copy shows a burst for one reading. Network use per process isn’t shown: Linux keeps no per-process byte counts that a user can read, and getting them takes root.
Hovering one of your own processes shows End. Clicking it turns it into Confirm; clicking that sends SIGTERM, which asks the program to quit. A program that’s still running 3 seconds later shows Force, which sends SIGKILL and stops it at once. Other users’ processes have no button. mochi ipc performance end <pid> and kill <pid> do the same from a shell, and refuse processes that aren’t yours.
A reading that stays over its notice level shows a short notice on the island, once, naming the busiest process, like “CPU at 92% · firefox” or “Memory at 88% · Discord uses 3.1 GB”. One that stays over its critical level shows a red notice and puts a red bubble with the reading next to the island until it comes back down. A spike says nothing: a reading must stay up for sustain_seconds. After a notice, a reading must fall 10 under the level before it can notify again, so one hovering at the level stays quiet. Disk and network speeds have no levels.
# Performance: CPU, memory and GPU use and temperatures, and disk and
# network speeds. The control center has a Performance page with graphs and the
# busiest processes, which it can end; readings that stay high show a
# notice, and critical ones a bubble. The GPU comes from AMD's sysfs or
# NVIDIA's nvidia-smi, which runs only while a view shows the GPU, since
# asking the driver can make games stutter: an NVIDIA GPU's levels count
# only then. Disk and network speeds have no levels.
[module.performance]
# How often to read, in milliseconds; at least 500.
# interval_ms = 2000
# How long a reading must stay over a level before it counts, so a spike
# says nothing.
# sustain_seconds = 10
# Levels in percent of use: over Notice, a short notice shows once, naming
# the busiest process; over Critical, a red bubble stays until it comes
# down. 0 turns a level off; one left out of a table takes 85 and 95.
# cpu = { notice = 90, critical = 98 }
# memory = { notice = 85, critical = 95 }
# gpu = { notice = 95, critical = 0 }
# The same for the CPU's and the GPU's temperatures, in °C.
# temperature = { notice = 85, critical = 95 }
# The rings look waves. Off keeps the rings flat. The theme's waves, under
# Motion, can keep every wave flat whatever this says.
# wavy = true
GPU use defaults to a notice only at 95% and no critical level, since a game keeps the GPU at full use. Clicking the bubble opens the page. mochi ipc performance status prints the readings.
The CPU’s temperature comes from hwmon (k10temp or zenpower on AMD, coretemp on Intel). An AMD GPU is read from sysfs; an NVIDIA GPU through nvidia-smi, which comes with NVIDIA’s driver. It runs only while a view shows the GPU, like the Performance page or a performance widget on screen, and for 30 seconds after, since asking the driver can make games stutter. So an NVIDIA GPU’s levels only count then. Intel GPUs aren’t read yet.
Disk speeds add up the whole disks in /proc/diskstats that have a device link in /sys/block. That leaves out partitions, which the disk already counts, and loop, RAM, zram, device-mapper and RAID devices, which pass their traffic on to a disk. Network speeds add up the interfaces in /proc/net/dev that have a device link in /sys/class/net: wired and wireless cards. That leaves out loopback, bridges, containers’ virtual cards and VPN tunnels, whose traffic crosses a card anyway.
The performance widget shows the same graphs, each turned on or off in its settings, or CPU, memory and disk as rings, or a bar for each reading. The rings wave; wavy = false in [module.performance] keeps them flat, as does the theme’s waves = false in [motion]. The disk there is the filesystem that holds your home directory, as full as df says. The module offers a system info widget too: the distribution, the kernel, the uptime, Mochi’s version, the compositor, the CPU and the memory in use. It reads what the computer is once, when it starts.
Notifications
The notification daemon. Popups show the app’s icon or picture, the app, the summary and the body; click one for the whole text and the app’s buttons, then Escape or a click outside closes it. A burst from one app shows only the latest. Critical notifications, like a low battery, stay until you close them.
Popups that time out go to the history, behind a bell bubble that counts them. Do not disturb sends everything but critical notifications straight to the history.
The body can have bold, italic, underline, line breaks and links (body-markup, body-hyperlinks). Mochi keeps <b>, <i>, <u>, <s>, <br> and <a href> to http, https, mailto and file URLs, drops every attribute but href, and shows any other tag as text. An image (<img>) shows its alt text instead, so a notification can’t make Mochi load a picture from the web. A click on a link opens it with xdg-open and closes the notification, in the popup and in the history.
Some apps, like Discord, send the Markdown their messages were typed in, so Mochi reads that too: **bold**, *italic* or _italic_, __underline__, ~~strike~~, `code` (shown without the backticks), [text](https://…) links, and ||spoilers||, which show as “spoiler” so the popup doesn’t give them away. Plain https://… links become links for every app. _ only counts at a word’s edge, so snake_case stays, and a mark needs text right inside it, so 2 * 3 * 4 stays too. markdown = false turns this off, if an app’s bodies have stars or underscores that aren’t meant as Markdown.
Apps that take a reply, like chat apps, send an inline-reply action, and Mochi advertises the inline-reply capability. That notification gets a Reply button; click it and type, then Enter sends the text back to the app as NotificationReplied, and Escape goes back to the buttons. A notification you clicked open never times out, so the text field waits for you. Notifications restored from before a restart have no Reply button, like their other buttons.
If another notification daemon runs, Mochi waits and takes over when it stops.
Sounds
Mochi advertises the sound capability and plays the sound an app asks for when its notification pops up: a file (sound-file) or a name from the sound theme (sound-name), like message-new-instant. A notification without either stays quiet, and so does one with suppress-sound. Files play through pw-play, or paplay without it. Names play through canberra-gtk-play when it’s installed, which uses the theme your GTK settings name. Without it, Mochi looks for sounds/<theme>/stereo/<name>.oga (or .ogg, .wav) in $XDG_DATA_HOME and $XDG_DATA_DIRS, in sound_theme and then in freedesktop, and tries shorter names too: message-new-instant, then message-new, then message. Most distributions ship the freedesktop theme as sound-theme-freedesktop.
Only a new popup makes a sound. An app updating its notification, like a download’s progress, doesn’t play it again, and neither does one going straight to the history. Do not disturb silences every sound, critical ones included. A new sound stops the one before it, so a burst of messages doesn’t play on top of itself, and no sound lasts more than 10 seconds.
Sounds are on by default, since apps only ask for one when they want it heard and GNOME and KDE play them too. sounds = false turns them off. sound_command replaces the players: it gets the file as its last argument, and names go through the theme lookup above first.
To try one:
notify-send --hint=string:sound-name:message-new-instant "Ada" "Lunch?"
notify-send --hint=string:sound-file:/usr/share/sounds/freedesktop/stereo/bell.oga "Bell" "Ding"
On NixOS the path starts with /run/current-system/sw/share instead.
Settings and actions
# Notifications: the notification daemon. If another one runs, Mochi waits
# and takes over when it stops.
[module.notifications]
# How long a popup stays unless the app asks for another time, in
# milliseconds.
# timeout_ms = 5000
# How many missed notifications to keep.
# history = 50
# "replace": a new popup from an app replaces the one shown, so a burst
# shows only the latest. "stack": each shows in turn.
# same_app = "replace"
# Keep the history across restarts, in $XDG_STATE_HOME/mochi/, readable
# only by you. Their buttons don't come back, since the apps that sent
# them can't answer anymore.
# save_history = true
# Read the Markdown some apps, like Discord, put in bodies: **bold**,
# *italic*, __underline__, ~~strike~~, `code`, [links](https://…) and
# ||spoilers||. Plain https:// links become links too.
# markdown = true
# Play the sound an app asks for when its notification pops up, like a
# chat app's message sound. Only notifications that ask make one, and none
# during do not disturb.
# sounds = true
# What plays a sound file; the file goes last. None uses pw-play or paplay
# for files, and canberra-gtk-play for sounds from the theme.
# sound_command = []
# The sound theme names like "message-new-instant" come from, when
# canberra-gtk-play isn't installed or a sound command is set above. Sounds
# it lacks come from the freedesktop theme.
# sound_theme = "freedesktop"
| Action | What it does |
|---|---|
history | Lists the missed notifications on the island |
clear | Removes every missed notification |
dnd on, dnd off, dnd toggle | Do not disturb |
dismiss <id> | Closes a notification |
invoke <id> <action> | Runs one of a notification’s buttons |
reply <id> <text> | Answers a notification that takes a reply |
open <id> <url> | Opens a link from a notification’s body, and closes the notification |
It offers the control center a card with the latest missed notifications, and a page with all of them.
Launcher
Grows the island into a search box. Your most used apps come first; typing searches names, descriptions and keywords, and app actions like Firefox’s “New Private Window” when you search for them. Enter or a click picks a result, Escape or a click elsewhere closes the launcher.
Apps and commands start through uwsm app in a uwsm session, otherwise through systemd-run, so they never belong to mochid.
Each result takes two lines by default: its name, and its description under it. With layout = "compact", each takes one line, the icon and the name, and nine fit where seven did; only the selected result shows its description, at the end of its line.
Providers
Results come from providers. These are built in:
| Provider | Prefix | Answers |
|---|---|---|
apps | none | Your apps and their actions |
windows | none | Open windows on every workspace whose title or app has every word you typed, the one focused last first, above the apps. Enter focuses one and switches to its workspace. Needs wlr-foreign-toplevel-management, which Hyprland, Sway and niri have |
calculator | = | Math, like =2^10 or =sqrt(2)*pi. Plain math like 2+2 works without the prefix, above the apps. Enter copies the result |
commands | > | A shell command, like > htop, with the ones you ran before. Enter runs it, Shift+Enter runs it in the terminal from terminal |
files | / | Files and folders in your home by name, from an index in memory. Enter opens one, Shift+Enter or the folder button shows it selected in your file manager, and dragging one drops it on another app |
| web searches | !w, !g, !gh, !yt, !nix, !wiki | !w rust opens a DuckDuckGo search for “rust”; the others search Google, GitHub, YouTube, NixOS packages and Wikipedia. engines adds more |
| emoji | : | Emoji by name. Enter types it into the window you were in, Shift+Enter copies it |
| colors | # | A color you type, in every format, or a pick from the screen |
| timer | :t | A timer of the length you type, like :t 10m Pizza, the running timers to pause, and the stopwatch with :t sw |
The emoji, colors and timer providers come from their modules, so they’re there when those modules run.
A query that starts with a provider’s prefix asks only that provider, with the rest of the query. Providers without a prefix answer every query, and their results show together under headings, in the providers’ order. The built-ins and modules answer at once; scripts a moment after you stop typing, and their results come in as they’re ready.
mochi ipc launcher open : opens the launcher with : typed, so a key can go straight to a provider.
The file index covers your home folder without hidden files and folders and build folders like node_modules and target, up to 200 000 entries. It’s built in the background the first time a search asks for files after you open the launcher, when there’s none or it’s more than 15 seconds old, so opening the launcher for apps never reads your home folder. Nothing runs in between. While it builds, the search field says “Indexing”, and a / search shows its files once it’s done.
With watch = true in [module.launcher.files], the index is built when Mochi starts and follows your files through inotify: a file or folder you make, delete, rename or move shows up in the results, or leaves them, right away, even with the launcher open. Every indexed folder takes one inotify watch, and every change in them wakes Mochi, which a busy home folder, like one with game installs or builds, makes costly. When the system runs out of watches (the fs.inotify.max_user_watches sysctl, 8192 on older kernels), mochid logs it once and goes back to building the index when a search asks for files.
The calculator knows + - * / % ^, parentheses, !, pi, e, tau, and the functions sqrt cbrt abs floor ceil round sin cos tan asin acos atan sinh cosh tanh ln log log2 exp min max pow, with trig in radians. A number before a name or a parenthesis multiplies, so 2pi works.
Script providers
A section with a command adds a provider of your own. The launcher runs the command with the query as its last argument, and in MOCHI_QUERY, and reads one result per line of what it prints:
{"title": "Search the web for rust", "subtitle": "https://duckduckgo.com/?q=rust", "icon": "web-browser", "open": "https://duckduckgo.com/?q=rust"}
| Key | |
|---|---|
title | Required |
subtitle | A second line |
icon | An icon theme name, or a file path |
glyph | A short text shown big in place of the icon, like an emoji |
color | A CSS color, shown as a round swatch in place of the icon |
copy | Enter copies this text, through the clipboard module, or wl-copy without it |
type | Enter pastes this text into the window you were in, through the clipboard module |
open | Enter opens this URL or file with xdg-open |
run | Enter runs this shell command, Shift+Enter in a terminal |
alt | What Shift+Enter does, as an object with one of the four: {"copy": "😀"}. A run result runs in a terminal on Shift+Enter without one |
id | Passed to the provider’s pick command after Enter |
file | A file or folder the result is: it drags out onto other apps, and Shift+Enter, without an alt, and the folder button show it in the file manager |
A result has at most one of copy, type, open and run. A newer query stops a script that hasn’t finished, and so does timeout_ms, 2 seconds by default. A script without a prefix isn’t asked for an empty query.
Two example scripts are in the repository’s examples/launcher, and the test suite runs both. The launcher has both built in now, faster, so they’re here to copy from. Web search:
#!/bin/sh
# A launcher provider: searches the web for what you type. In config.toml:
#
# [module.launcher.providers.web]
# prefix = "!w"
# title = "Web"
# command = ["sh", "/path/to/web-search.sh"]
#
# The launcher runs it with the query as its last argument and reads one
# JSON result per line. Set SEARCH_URL to use another engine; the query
# goes at its end.
query=$1
[ -n "$query" ] || exit 0
engine=${SEARCH_URL:-https://duckduckgo.com/?q=}
# Every byte but letters, digits and -._~ becomes %XX.
encode() {
printf '%s' "$1" | od -An -v -tx1 | tr -s ' \n' ' ' | {
read -r bytes
for byte in $bytes; do
case $byte in
3[0-9] | 4[1-9a-f] | 5[0-9a] | 6[1-9a-f] | 7[0-9a] | 2d | 2e | 5f | 7e)
printf "\\$(printf '%03o' "0x$byte")" ;;
*) printf '%%%s' "$(printf '%s' "$byte" | tr 'a-f' 'A-F')" ;;
esac
done
}
}
# A JSON string's inside: backslashes and quotes escaped.
json() {
printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'
}
url=$engine$(encode "$query")
printf '{"title": "Search the web for %s", "subtitle": "%s", "icon": "web-browser", "open": "%s"}\n' \
"$(json "$query")" "$(json "$url")" "$(json "$url")"
Files and folders in your home, through fd when installed:
#!/bin/sh
# A launcher provider: finds files and folders in your home by name, and
# opens the one you pick. In config.toml:
#
# [module.launcher.providers.files]
# prefix = "/"
# title = "Files"
# command = ["sh", "/path/to/files.sh"]
#
# It uses fd when installed, find otherwise, and skips hidden files. Set
# FILES_ROOT to search somewhere else than your home.
query=$1
[ -n "$query" ] || exit 0
root=${FILES_ROOT:-$HOME}
json() {
printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'
}
if command -v fd >/dev/null 2>&1; then
fd --max-results 30 --fixed-strings --ignore-case -- "$query" "$root"
else
find "$root" -name '.*' -prune -o -iname "*$query*" -print 2>/dev/null | head -n 30
fi | while IFS= read -r path; do
path=${path%/}
[ "$path" = "$root" ] && continue
if [ -d "$path" ]; then icon=folder; else icon=text-x-generic; fi
printf '{"title": "%s", "subtitle": "%s", "icon": "%s", "open": "%s"}\n' \
"$(json "${path##*/}")" "$(json "${path%/*}")" "$icon" "$(json "$path")"
done
Plugins can offer providers too, with results from their backend: see Launcher providers. The example emoji picker in examples/plugins/emoji is one, with ;.
# Launcher: `mochi ipc launcher toggle` searches your apps. Bind it to a key.
[module.launcher]
# The terminal that runs terminal apps when uwsm doesn't. None picks
# xdg-terminal-exec when it's installed, otherwise the one $TERMINAL names.
# terminal = []
# The most results to list.
# max_results = 50
# How results are listed: Comfortable, two lines each, the name and its
# description, or Compact, one line each, with the description only on the
# selected one.
# layout = "comfortable"
# Providers: where results come from. The built-ins are "apps", "calculator"
# (prefix "=", and plain math like 2+2 without it), "commands" (prefix ">";
# Shift+Enter runs one in a terminal), "files" (prefix "/"; Shift+Enter opens
# the folder) and the web searches below. Modules offer more: emoji with ":"
# and colors with "#". A
# [module.launcher.providers.<name>] section changes one, with any of:
#
# enabled = false # turn it off
# prefix = "c" # what a query starts with to ask only it; "" for none
# order = 5 # lower shows first; apps are at 0
# title = "Maths" # the heading over its results
#
# A section with a command adds a script provider. It runs with the query
# as its last argument, and prints one JSON result per line, like
# {"title": "Rust", "subtitle": "rust-lang.org", "open": "https://rust-lang.org"}
# with at most one of copy, type, open or run for what Enter does:
#
# [module.launcher.providers.web]
# prefix = "!w"
# command = ["sh", "/path/to/web-search.sh"]
# timeout_ms = 2000 # stopped after this long
# pick = ["my-script", "--picked"] # run with a result's "id" once picked
# Web searches, by the word after "!": "!w rust" searches DuckDuckGo. Built
# in are w (DuckDuckGo), g (Google), gh (GitHub), yt (YouTube), nix (NixOS
# packages) and wiki (Wikipedia). A section adds one, or changes or removes
# a built-in one with an empty url; %s is where the query goes:
#
# [module.launcher.engines.crates]
# title = "crates.io"
# url = "https://crates.io/search?q=%s"
# The files provider searches an index of your home folder, built in the
# background the first time a search asks for files each time the launcher
# opens, when the index is gone or 15 seconds old; the search field says "Indexing" meanwhile. With
# `watch = true` it's built when Mochi starts and kept up to date through
# inotify, one watch per folder, which costs memory and wakes Mochi on every
# change in them; without enough watches (fs.inotify.max_user_watches), it
# falls back to building on open.
# Hidden files and folders are left out, and these:
#
# [module.launcher.files]
# roots = ["~"]
# ignore = ["node_modules", "target", "__pycache__", "venv", "result", "dist", "build"]
# max = 200000
# watch = false
| Action | What it does |
|---|---|
toggle, open, close | Shows or hides the launcher |
launch <id> | Starts an app by desktop id, like firefox.desktop |
The launcher sends search and activate itself.
Lock
Mochi’s own lock screen, in place of hyprlock or swaylock. It’s off until you add "lock" to modules, and it needs a PAM service, below.
A small program of its own, mochi-lock, takes the compositor’s session lock (ext-session-lock-v1, which Hyprland, niri and Sway have) and checks your password with PAM. From the moment the compositor confirms the lock, it shows nothing but the lock screen on every monitor, a monitor plugged in while locked too, and gives the keyboard to nothing else. Only mochi-lock can unlock, and only once PAM accepts the password: there is no command that unlocks, and logind’s unlock request is ignored.
By default the lock screen shows the time, big, with the date and the weather under it, and on the right what’s playing, with play, pause and skip, and the field, with a dot for each character typed. The battery’s level sits in a corner. Behind it all is your wallpaper, blurred and dimmed. Escape or Ctrl+U clears the field, Enter checks it. After a wrong password it says so, or says what PAM said, like an account locked after too many tries; from the third wrong one in a row, Enter waits 2 seconds, then 4, 8 and so on, up to a minute, on top of PAM’s own delays. It says when Caps Lock is on. Its colors and fonts are the theme’s.
background in [module.lock] picks what’s behind it: the wallpaper that awww, swww or hyprpaper shows, or Hyprland’s own when none does; an image; a screenshot of each monitor taken just before locking, open windows and all; or the theme’s color. The images are blurred. A screenshot is taken only for a lock you start, never for a lock screen started again after a crash, which would only show the lock, and it’s deleted once unlocked. Wayland has no way to capture only what’s under the windows, so a screenshot shows them, blurred. mochi ipc lock edit arranges what’s on it. Weather shows once the weather module runs with a place, and what’s playing once the media module runs.
Arranging it
mochi ipc lock edit, or Arrange the lock screen on the Lock page of the settings, arranges the lock screen the way mochi ipc widgets edit arranges the desktop: over its background, with the same grid, dragging, resizing, settings and layers, and the island’s notice opening the drawer. The drawer has every widget, and the password field. Run it again, Escape or Done to stop.
On the lock screen, widgets only show: they never get a key, so a note can be read but not typed into, and their buttons do nothing but play, pause and skip what’s playing. What they show is yours to decide: a note or a to-do list on the lock screen can be read by anyone at the screen. Plugins’ widgets go there only with lock_plugins = true in [module.widgets]. A widget can keep itself off the lock screen with places = ["desktop"] in its offer.
The password field is always there: it can’t be removed, only moved and resized, and a layout without one gets it back.
The layout is kept in lock-widgets.toml, next to widgets.toml, in the same form; the default one has the clock on the left, the weather under it, what’s playing over the field on the right and the battery in a corner. A widget whose output is empty, as in the default, shows on every monitor.
How it draws
mochi-lock holds the lock and the keyboard. The lock screen itself is Quickshell, like the rest of Mochi, but it draws on a small display of mochi-lock’s own, not on your compositor: mochi-lock copies what it draws onto the lock’s surfaces. That display has no keyboard, so the lock screen’s views never see a key: they show as many dots as mochi-lock says, and nothing else about the password reaches them. They can’t unlock, and the commands they may ask for are play, pause and skip, which mochi-lock and mochid both check. Only Quickshell’s own process may connect to that display, and it runs without the variables that would lead it to your compositor or its IPC.
Until the lock screen draws, or when it stops drawing a change within a moment and a half, or crashes, mochi-lock draws a plain face of its own: the time, the date and the field. It starts the lock screen again after a crash. Either way the password works the same.
When it locks
mochi ipc lock lock, bound to a key or run from a script.- When logind asks:
loginctl lock-session, the power module’s Lock, or an idle daemon. hypridle’s usuallock_cmd,loginctl lock-session, works as is. - Before the computer sleeps: Mochi holds the sleep back until the compositor confirms the lock, 2 seconds at most, so waking up never shows the desktop.
The power module’s lock setting, when set, runs that command instead, like ["hyprlock"].
What it forgets
Once the screen is locked, the auth module, when it runs, forgets sudo’s password, the SSH keys in the agent, polkit’s admin actions and the keyring, or keeps them as long as its settings say.
Setting it up
mochi-lock checks the password with the PAM service mochi, a file in /etc/pam.d. Without it, Mochi refuses to lock, since nothing could unlock the screen, and says so on the island.
- NixOS: the NixOS module adds it, unless
programs.mochi.lock.enable = false. Without the module, addsecurity.pam.services.mochi = {};to your system’s configuration. - Arch: the packages install
/etc/pam.d/mochi. - The release archive:
sudo install -m644 ~/.local/share/mochi/pam.d/mochi /etc/pam.d/mochi.
Or point pam_service at a service you have, like hyprlock. On Hyprland, set misc:allow_session_lock_restore = true, so a new lock screen can take over from one that crashed. mochi doctor checks all of this.
# Lock: Mochi's own lock screen. A small program of its own, mochi-lock,
# holds the lock and checks the password with PAM; nothing else unlocks it.
[module.lock]
# The PAM service that checks the password, a file in /etc/pam.d. Mochi
# refuses to lock without it, since nothing could unlock the screen. On
# NixOS, `security.pam.services.mochi = {};`; the Arch package brings it.
# pam_service = "mochi"
# Lock before the computer sleeps, and let it sleep once the screen is
# locked, so waking up never shows the desktop.
# before_sleep = true
# Lock when logind asks: `loginctl lock-session`, the power module's Lock,
# or an idle daemon like hypridle. logind's unlock is never obeyed.
# logind = true
# Behind the lock screen: "wallpaper", the one awww, swww or hyprpaper
# shows, or Hyprland's own when none does, blurred; "image", the image
# below, blurred; "screenshot", each monitor as it was just before
# locking, blurred, open windows and all; or "none" for the theme's
# background.
# background = "wallpaper"
# image = ""
# What's on the lock screen, and where, is arranged like desktop widgets:
# `mochi ipc lock edit`, or Arrange the lock screen at the top of this
# page. It's kept in lock-widgets.toml next to widgets.toml.
| Action | What it does |
|---|---|
lock | Locks the screen |
status | Says locked, locking or unlocked |
edit | Arranges the lock screen’s widgets, or stops |
When something fails
If mochi-lock crashes or is killed, the compositor keeps the screen locked: it shows nothing of your desktop, on Hyprland and Sway a plain color. Mochi starts the lock screen again within a moment. A lock outlives Mochi itself too: a restarted mochid finds it and watches it, or starts a new one if it’s gone.
If nothing comes back, switch to another TTY with Ctrl+Alt+F2, log in, and run WAYLAND_DISPLAY=wayland-1 mochi-lock, with your session’s display, to take the lock over and unlock it with your password.
What it defends against
Someone at your keyboard while you’re away: typing, clicking, plugging in a monitor, closing the lid, or waiting for something to crash. Not a program already running as you, which could read your keystrokes anyway, and not someone logging in on another TTY with their own account.
What’s typed stays in mochi-lock: it’s never written to a log, never sent to mochid, and wiped from memory after each try. An empty password never unlocks, whatever the PAM service would say.
Auth
Passwords and what the session remembers of them. polkit’s admin passwords, the keyring’s, and those sudo -A and ssh ask for are typed on the island, and locking the screen forgets sudo’s password, the SSH keys in the agent, the admin actions polkit remembers and the keyring’s unlocked secrets.
It’s off until you add "auth" to modules. It takes over password prompts for the whole session, so it waits until you choose it.
Admin passwords
When an app needs an admin action, like pkexec, systemctl restart, run0 or a settings app, polkit asks Mochi, and the island shows a prompt: which program asks, polkit’s reason, and for pkexec the command it would run. When several users may allow it, a choice picks who types. Enter checks the password, Escape or Cancel declines, and three wrong tries end it. A wrong one clears the field and says so.
Mochi never checks the password itself: polkit’s own helper does, with PAM, and tells polkit. The password goes from the island to the auth module and on to the helper, and isn’t kept or logged.
Only one polkit agent answers for a session. If another runs, like hyprpolkitagent, Mochi logs that it can’t answer and the other one keeps asking. Turn it off: with the home-manager module, programs.mochi.polkitAgent.enable turns off services.hyprpolkitagent; otherwise stop its service or remove it from the compositor’s autostart. polkit = false in [module.auth] leaves polkit to another agent.
The keyring
gnome-keyring asks for passwords through a prompter on the session bus, GNOME’s gcr-prompter by default. Mochi takes its place, so the island asks: to unlock a keyring, for a new keyring’s password, typed twice, and for the passphrases gcr’s SSH agent needs. The prompt shows what the keyring says, with its choice to tick when it has one, like unlocking the keyring at login. A wrong password brings the keyring’s own warning. The password goes back to gnome-keyring encrypted, with the key exchange gcr uses, so it isn’t readable on the bus.
While gcr-prompter runs, it keeps the prompts: it exits after a few idle seconds, and Mochi takes them from then on. keyring = false in [module.auth] leaves them to gcr-prompter.
sudo and ssh
sudo -A, and ssh when it has no terminal, run the program in SUDO_ASKPASS or SSH_ASKPASS to ask for a password. Point both at mochi-askpass, which comes with Mochi, and they ask on the island: what the program asks, in its words, with Continue and Cancel. Cancel makes sudo or ssh stop. The home-manager module’s askpass.enable sets both.
- Plain
sudokeeps asking in its terminal.alias sudo='sudo -A'sends it to the island;run0asks through polkit already. - ssh asks on the island from a terminal too with
SSH_ASKPASS_REQUIRE=prefer. - For an SSH key’s passphrase, the prompt has a choice of how long the key stays in the agent once added: until the screen locks, 1, 4 or 8 hours, or until logout, starting from
remember_ssh_keys. ssh adds the key withAddKeysToAgent yesin its config, orssh-adddoes. - ssh’s yes or no questions, like confirming each use of a key, have Yes and No. Its notices, like touching a security key, show for a while and need no answer.
The password goes from the island to the auth module, back to mochi-askpass and to the program that ran it. Any program of the user’s could run mochi-askpass too, so the prompt says which program asks: the one that ran it, as the kernel says, with its command line. Before it shows the prompt without a warning, Mochi checks that the answer goes only to that program: mochi-askpass answers on a pipe, and the program named is the only one Mochi sees reading it. A program running as root also has to be sudo started with -A, with nothing else started. That’s how sudo shows as running as root, which no other program of the user’s can show. It checks again before the answer goes out, and if anything changed, it keeps the answer and says why. A red line under the prompt says to look twice when the program runs from a folder you can write to, asked Mochi without mochi-askpass, exited before the prompt showed, or doesn’t pass the check. The command line is the program’s own to set, so trust the name above it more.
Only the island answers a prompt. mochi ipc auth answer from anything else, even a program that connects as the UI, is refused, so no program can say Yes to ssh’s questions for you. mochid knows who wrote each message from the kernel, for every message, so a program can’t pass a connection to another or become mochi after connecting to look like it. If the UI isn’t the Quickshell mochid started, like one started by a --quickshell script that doesn’t exec it, the island can’t answer prompts at all; mochid logs it, and mochi doctor says so.
What it remembers
By default, all of them are forgotten once the screen is locked, and whoever unlocks types them again. Each can be remembered longer, with a setting in [module.auth]:
| Setting | Choices | Default |
|---|---|---|
remember_ssh_keys | until-locked, 1h, 4h, 8h, until-logout | until-locked |
remember_keyring | until-locked, 1h, 4h, 8h, until-logout | until-locked |
remember_sudo | until-locked, own-timeout | until-locked |
remember_polkit | until-locked, own-timeout | until-locked |
A time counts from when the key was added or the keyring unlocked, or from when Mochi started for one that was already there, and a lock doesn’t cut it short. Mochi checks every minute and takes back what’s been there longer: ssh-add -d for a key, however it was added, and the Secret Service’s Lock for the keyring, gnome-keyring’s or KeePassXC’s. until-logout leaves them to the agent and the keyring. sudo and polkit never keep a password longer than their own timeout, 5 minutes unless their configuration says otherwise, so own-timeout only keeps it through a lock.
Taking things back never holds the lock back, and one that fails, or finds nothing, doesn’t stop the others.
When the screen locks
Locking happens in several ways, and the module hears of each:
- logind’s Lock:
loginctl lock-session, hypridle’s usuallock_cmd, and the power module’s Lock with nolocksetting. - The lock module, once its lock is on screen.
- The power module’s Lock with a
lockcommand of its own, like["hyprlock"], once it has started it. mochi ipc auth locked, for a keybinding that starts a locker directly:hyprlock & mochi ipc auth locked.
mochi ipc auth forget forgets everything at once, whatever the settings say.
What it can’t stop
The prompts protect against programs that aren’t yours. A program you run, with your user’s rights, has more ways in:
- It can run
mochi-askpassitself and gets the password you type. The prompt names it, from the file it runs, and the red line warns when something looks off. Read the name before typing: sudo asks as root, and ssh and ssh-add ask for a key’s passphrase. - A program can hide its open files from Mochi (
PR_SET_DUMPABLE), as ssh-agent does. One like that could read the pipe the answer goes on without Mochi seeing it. It has to run as you already. A prompt you didn’t start is the sign to look for. - It can ask for a keyring password over the session bus, as gnome-keyring does, and gets what you type. gcr-prompter has the same gap. Mochi’s keyring prompts don’t say who asks yet.
- The password passes through mochid and Quickshell. Mochi’s Rust code clears its own copies once they’re used, but socket buffers and Quickshell’s JavaScript keep theirs until that memory is reused. Only a program running as you can read them there.
- Plugins’ views run inside the shell, beside the island’s own, so a plugin can answer a prompt as the island does. Install plugins you trust.
mochi-askpasscounts as Mochi’s only beside the mochid that runs. After an update, until mochid restarts, every prompt warns that the program asked directly. home-manager restarts it on switch.
No other program can answer a prompt for you: only the island does.
Control center
A panel that grows out of the island: a home screen of cards, and pages in a navbar at the bottom. It has no content of its own: every card and page comes from a module. The clock gives the Today card with the time and the date, and a page with its tabs, media a Now Playing card, audio a volume card and a Sound page, brightness a slider per display and one for the keyboard, night light a tile, notifications a card and a page, power a page, clipboard a card and a page, capture a Captures page, network a card and a page, bluetooth a tile and a page, battery a card with the peripherals’ batteries, performance a page, the focus timer a card, weather a card with the next hours, a smaller one and a page. A module that isn’t running provides nothing.
Clicking the clock opens it, and Escape or a click elsewhere closes it. A card whose module also has a page shows a chevron by its heading: clicking the heading, or the card beside its controls, opens that page.
| Action | What it does |
|---|---|
toggle, close | Shows or hides the control center |
open [page] | Opens it, on a page like power/power |
edit | Opens it arranging the home and the navbar, as the pencil does |
arrange <order> [hidden] | Keeps the home’s cards in an order and hides some, each a comma-separated list of cards like network/status |
arrange-pages <pages> [hidden] | Keeps the navbar’s pages in an order and hides some, the same way, with pages like weather/page |
It used to be called the hub. hub still works in config.toml, in mochi ipc hub ... and in plugin manifests, with a warning in the log, so older configs and keybinds keep working until you change them.
The home is a grid of three columns. The control center draws each card’s frame, with the card’s icon and title at the top, and places the cards in order, each in the first spot where it fits. A card is one or more columns wide and one or two rows tall. With the default modules, the first row has the Network toggles (two columns) and Bluetooth, the second Today, the latest missed notification and the battery, then Now playing takes two columns and two rows beside Clipboard and Colors, and the weather (two columns) comes last. Plugin cards come after. Some cards are spare, like the weather’s one-column card: they wait under “More cards” until you put them on the home.
Arranging the home and the navbar
The pencil at the right of the navbar, or mochi ipc control-center edit, arranges the home and the navbar. Every card gets an outline: drag one onto another to put it there, and its minus takes it off. The cards taken off wait under the others, under “More cards”; a click puts one back at the end. The navbar’s pages get an outline and a minus too: drag a page along the navbar onto another to put it there, and its minus takes it out of the navbar. The pages taken out wait under “More pages”; a click puts one back at the end. Home stays first. Done keeps the arrangement, and Escape leaves everything as it was. The control center stays open while it saves.
The arrangement lives in four settings, order and hidden for the cards, and pages and hidden_pages for the navbar, written to changes.toml like the settings panel’s changes, so Copy in the settings panel hands them to your Nix or TOML config. Done writes only what changed, so moving a card leaves the navbar’s settings alone. Cards and pages listed come first, in that order; the others follow in their own. A module’s card or page that appears later, from a module you turn on, joins at the end.
A page out of the navbar still opens: mochi ipc control-center open weather/page opens it, and so does its card’s heading. While it’s open, its tab shows in the navbar so you see where you are, and it leaves with the next page you pick. To be rid of a page altogether, turn its module off.
The panel takes the height of what it shows, up to height and the screen; a longer page scrolls, and the navbar stays in place.
# Control center: the panel `mochi ipc control-center toggle` opens, with
# cards on its home and pages in a navbar.
[module.control-center]
# Its width, and the most its cards or a page take above the navbar, in
# logical pixels: the control center takes the height its content needs, up
# to that, and what is taller scrolls. It never grows past the screen.
# width = 860
# height = 480
# The home's cards in this order; the ones not listed follow. The pencil in
# the control center's navbar arranges them too.
# order = []
# Cards to leave off the home.
# hidden = []
# The navbar's pages after Home in this order; the ones not listed follow.
# The pencil arranges them too.
# pages = []
# Pages to leave out of the navbar. They still open from their cards.
# hidden_pages = []
Power
A page in the control center with lock, log out, suspend, hibernate, reboot, reboot to firmware and shut down. Only what the machine allows shows. Logging out, rebooting and shutting down take a second click, so a stray click never ends your session. When power-profiles-daemon runs, the page also switches between Power saver, Balanced and Performance.
Keep awake
The page’s Keep awake switch, or mochi ipc power awake, keeps the screen on and the machine awake: no screen lock, no screen off and no automatic sleep. It works two ways at once. Mochi holds a logind inhibitor for idle and sleep, which hypridle and systemd’s automatic suspend respect, and the island asks the compositor not to go idle through Wayland’s idle inhibit protocol, which swayidle and Hyprland respect. A cup stays next to the island while it’s on; a click on it turns it off. Closing the lid or picking Suspend still suspends.
# Power: lock, log out, suspend, reboot and shut down, as a page in the
# control center.
[module.power]
# Commands that replace the defaults. Lock asks logind to lock the session,
# which your locker answers; log out is `uwsm stop` under uwsm, otherwise
# logind ends the session. Like: lock = ["hyprlock"]
# lock = []
# logout = []
# Keep awake has no settings: `mochi ipc power awake` or the switch on the
# control center's Power page turns it on, and a click on its bubble turns
# it off.
| Action | What it does |
|---|---|
lock, logout, suspend, hibernate, reboot, firmware, shutdown | Act at once, without asking |
profile <name> | Switches the power profile |
awake [on|off|toggle] | Keeps the machine awake, or stops; flips it without an argument |
Privacy
An icon next to the island while an app records from a microphone or has a camera open: a microphone in orange, a camera in green, or both. A muted microphone shows crossed out and grey, since whoever records hears nothing. A click on the bubble mutes the default microphone, or unmutes it.
With wide = true in [bubbles.privacy], the bubble names the apps:
[bubbles.privacy]
wide = true
The microphone comes from the audio module, which lists the apps recording from an input. It leaves out Mochi’s own level meters and recordings of what an output plays, like a visualizer. Without the audio module, nothing shows for the microphone.
The camera comes from /proc: the processes with a /dev/video* device open, checked every 2 seconds. An app that uses the camera through PipeWire shows as pipewire, which opened the device for it.
# Privacy: a microphone or camera icon next to the island while an app uses
# them. A click mutes the microphone, or unmutes it.
[module.privacy]
# Apps recording from a microphone, which the audio module reports; without
# it, nothing shows for the microphone.
# microphone = true
# Apps with a camera open, from /dev/video* in /proc, checked every 2
# seconds.
# camera = true
mochi ipc privacy status prints who uses what.
Capture
Screenshots and screen recordings, picked on the island.
mochi ipc capture screenshot freezes every screen and opens the picker in its default mode, a region unless mode says otherwise, so you can drag right away. The island shows Region, Window, Screen and All screens: click one, or press Tab or a number, to switch. Over the frozen screens you drag a region, click a window, click a screen, or click anywhere for all of them as one image. A region can run from one screen into the next, and the screenshot joins their parts at the sharpest screen’s scale, with any gap between screens left transparent. Recordings take one screen at a time. A region can be moved and resized by its corners before you take it with Enter, a double click or the Capture button. The screenshot goes to ~/Pictures/Screenshots and to the clipboard, and the island shows it for a few seconds with buttons to copy it again, open it in an editor, open its folder or delete it. Escape or a right click cancels. The picker opens over anything on the island, the launcher or the control center included, and the frozen screen still shows it, so you can capture the shell itself; it comes back afterwards.
mochi ipc capture record picks the same way over the live screens, then records. A red dot next to the island shows while it records; mochi ipc capture stop or record again stops it, and the island shows the file in ~/Videos/Recordings. Clicking the dot opens the recording’s controls: the time, Stop, and for a recording of a whole screen a button for each screen. Clicking another screen goes on recording there, and mochi ipc capture switch [screen] does the same, to the next screen without one. The recorder records one screen at a time, so each screen makes a part in a hidden folder beside the recording, and ffmpeg joins them once it stops: as they are when the screens have the same size, which takes a moment, or encoded again otherwise, each part scaled into the first screen’s size with black bars. Without ffmpeg, the parts stay beside the recording as “part 1”, “part 2” and so on. While a recording is being picked, the island also has toggles for the desktop audio (A) and the microphone (M). record_audio and record_microphone set how they start. Two buttons set the quality: the frame rate (F) steps through 15, 30, 60, 90 and 120 fps, and the resolution (Q) through Native, 480p, 720p, 1080p and 1440p. A resolution scales the video down to that many lines, keeping its shape, and never scales it up. Two more set the encoding: the codec steps through Auto and every codec gpu-screen-recorder lists on your machine, like HEVC (Vulkan) or H.264 (CPU), and the file through MP4, MKV, which survives the recorder stopping hard, and WebM, which only shows when a codec that fits it, AV1, VP9 or VP8, is there. framerate, resolution, codec and container set how they start.
Give a mode to open in it instead of the default: screenshot window, or screenshot screen, which takes the focused monitor at once.
# Capture: screenshots and recordings. `mochi ipc capture screenshot` and
# `mochi ipc capture record` ask what to capture; bind them to keys.
[module.capture]
# The mode the picker opens in. All takes every screen as one image, for
# screenshots only; a recording opens on Region instead. The island
# switches it while picking.
# mode = "region"
# Where screenshots go. Default is Screenshots in your Pictures folder.
# screenshots = ""
# Where recordings go. Default is Recordings in your Videos folder.
# recordings = ""
# What a screenshot's file is called, with when it was taken.
# screenshot_name = "Screenshot from %Y-%m-%d %H-%M-%S"
# What a recording's file is called, with when it started.
# recording_name = "Recording from %Y-%m-%d %H-%M-%S"
# The editor the Edit button opens a screenshot in. None hides the button.
# editor = ["satty", "--filename"]
# The recorder, with any options of your own. It needs to speak
# gpu-screen-recorder's options.
# recorder = ["gpu-screen-recorder"]
# The video codec recordings start with, like "h264_vulkan" or "hevc". ""
# picks one: a hardware encoder when the GPU has one, otherwise Vulkan, and
# the CPU as a last resort.
# codec = ""
# The frame rate and the resolution recordings start with; the picker
# steps through 15, 30, 60, 90 and 120 fps, and "native", "480p", "720p",
# "1080p" and "1440p". A resolution scales the video down to that many lines,
# keeping its shape, and never up.
# framerate = 60
# resolution = "native"
# The file a recording goes in: "mp4", "mkv", which survives the recorder
# stopping hard, or "webm", which takes only AV1, VP9 and VP8. The picker
# steps through these and through the codecs the recorder has.
# container = "mp4"
# The sound to record, and the microphone the picker can add. Empty records
# none.
# audio = "default_output"
# microphone = "default_input"
# Whether the picker starts with the desktop audio and the microphone on.
# Its bar switches either for one recording.
# record_audio = true
# record_microphone = false
# Copy every capture to the clipboard: screenshots as images, recordings
# as files.
# copy = true
# How long the island shows a capture, in milliseconds.
# preview_ms = 6000
Recording
Recordings go through gpu-screen-recorder, which encodes on the GPU. Install it, and on NixOS enable its capture helper, which records a region or a screen:
programs.gpu-screen-recorder.enable = true;
The module asks gpu-screen-recorder which video codecs work on your GPU and picks one: a hardware encoder when there is one, otherwise Vulkan encoding, which works on cards whose driver is too old for NVENC, and the CPU as a last resort. Set codec to force one.
A window recording goes through the screen-cast portal, so it records that window alone, even behind others. The portal’s picker chooses the window.
Windows
No standard Wayland protocol says where windows are, so picking a window needs the compositor’s IPC. Hyprland’s works today; elsewhere, screenshots offer only Region and Screen.
Actions
| Action | What it does |
|---|---|
screenshot [region|window|screen|all] | Takes a screenshot, picking in the default mode without one; screen and all take it at once |
record [region|window|screen] | Starts recording, or stops the recording |
mode <region|window|screen> | Switches what the open picker captures |
stop | Stops recording |
switch [screen] | Goes on recording a whole screen on another one, the next without one |
cancel | Closes the picker |
copy, edit, delete, open [path] | Act on the last capture, or on a file from the history: copy it, open it in the editor, delete it, open its folder |
preview <path> | Shows a file from the history in the preview card |
The picker sends audio, microphone, framerate, resolution, frame, region, select and confirm itself, and the control center page history and start. framerate [fps], resolution [preset], codec [name] and container [mp4|mkv|webm] also take a value, like mochi ipc capture framerate 30 or mochi ipc capture codec hevc_vulkan.
The Captures page
The control center has a Captures page: the newest 40 screenshots and recordings in their folders, newest first, each with a thumbnail. A recording’s is a frame ffmpeg picks among its first, made once in the background and kept in $XDG_CACHE_HOME/mochi/thumbnails; the card after a recording shows it too, once it’s ready. Without ffmpeg, recordings show a camera instead. Files other tools saved there show up too. Click one to open it in the preview card; each row also copies it, opens a screenshot in the editor, opens its folder or deletes it. Hold a row and drag it onto another app to drop the file there, as from a file manager. Shift+click or Ctrl+click selects several, and dragging one of them drops them all. Its Screenshot and Record buttons close the control center before the picker opens, so the control center isn’t in the capture. mochi ipc control-center open capture/history opens the page.
copy, edit, delete and open take a file from the history, like mochi ipc capture delete <path>; without one they work on the last capture. Only files the history lists can be deleted this way.
The clipboard opens its images in the same card, through the show <path> <entry> [label] action: copy and edit work as for a screenshot, there’s no folder, and delete removes the clipboard entry.
Share
The picker that opens when an app asks to share your screen, and a bubble while something shares it.
When an app like Discord or OBS asks xdg-desktop-portal-hyprland for the screen, the island grows into a panel. It shows your screens and the windows the portal offers, each with a live picture, windows on other workspaces included. Click one, or move with the arrows and Tab and press Enter, to share it. Region (or R) lets you drag an area over the screen instead; Escape or a right click goes back. Remember lets the app keep the choice for next time. Escape, or a click outside, shares nothing.
Switching what you share
The portal can’t change what a running share captures, so by default Mochi shares a copy you can switch. The app gets a monitor of Mochi’s own, MOCHI-SHARE, and Mochi draws a live copy of the screen, window or region you picked on it, pointer included. Click the sharing bubble, or run mochi ipc share switch, and the picker opens again: pick something else and the copy changes at once. The app keeps sharing the same monitor, so it never asks again, and the people watching see the new source.
MOCHI-SHARE is a Hyprland headless monitor, placed far from your screens so the pointer and your windows never reach it, at the size of your largest screen. It gets no island, and a workspace of its own, name:mochi-share, so the numbered workspaces stay on your screens. A source with another shape is scaled to fit, with black around it.
The monitor is there whenever Switchable is on, shared or not, and shows black while nothing is shared. The portal only finds monitors that existed before the app asked, so a monitor made during the pick would fail the first share. A share ends a few seconds after the app stops capturing the monitor, or 30 seconds after the pick if the app never starts, and the monitor waits for the next one. Mochi removes it when the share module stops or switchable is off, and places it again after a hyprctl reload, which drops the rule that keeps it away from your screens.
A restart of mochid, or a reload that restarts the share module, doesn’t end the share. While the app captures MOCHI-SHARE, Mochi leaves the monitor in place, and the next start draws the copy on it again, with the same source and quality. The app sees the stream pause for the moment the copy is gone and carry on, without sharing again. The bubble comes back too.
With Switchable on, the picker also sets the quality the app receives: the frame rate (15, 30, 60, 90 or 120 fps) is the switchable monitor’s refresh rate, and the resolution (Native, 480p, 720p, 1080p or 1440p) its size, scaled down from your largest screen with its shape kept. Each click steps to the next preset; framerate and resolution in the settings set how they start. The picker the bubble opens has them too, starting from the share’s current quality, and a click there changes the running share at once: Mochi resizes its monitor, and the app gets a stream of the new size or pace, as when a shared window is resized. The app can still send less, like Discord without Nitro. A share that isn’t switchable leaves the quality to the app.
Turn off Switchable in the picker to share the choice itself for one share, or set switchable = false for every share. Without the switchable copy, Remember lets the app keep the choice, which a monitor that only exists while it’s shared can’t offer. Switching needs Hyprland; elsewhere the picker shares the choice itself.
# Share: the screen-share picker for xdg-desktop-portal-hyprland, and a
# bubble while something shares the screen.
[module.share]
# Share a switchable copy by default: the app gets a monitor of Mochi's own
# with a live copy of what you pick, and clicking the bubble picks something
# else without the app asking again. The picker's Switchable switch changes
# it for one share. Hyprland only.
# switchable = true
# The switchable copy's frame rate and resolution, which the picker steps
# through: 15, 30, 60, 90 and 120 fps, and "native", "480p", "720p", "1080p"
# and "1440p". "native" is your largest screen's size; the others scale it
# down to that many lines, keeping its shape. The app may still send less.
# framerate = 60
# resolution = "native"
The bubble
While the screen is shared, a screen icon breathes next to the island. It shows once a capture has lasted a second and a half, so a screenshot’s one-frame capture doesn’t light it up, and never for the picker’s own previews.
Hyprland only reports a capture when it starts or stops, so the share module writes down what’s captured in its session directory, and gives it back to the compositor when mochid starts again within two minutes. A share that started before a restart keeps its bubble, and the bubble goes when that share stops.
Setup
The portal runs one program as its picker. The Nix package has it as mochi-share-picker, and the home-manager module points the portal at it in ~/.config/hypr/xdph.conf (programs.mochi.portalPicker.enable, on by default). The Arch packages install it as /usr/bin/mochi-share-picker. Elsewhere, write that file yourself, with a small script that runs mochi share-pick "$@":
screencopy {
custom_picker_binary = /path/to/mochi-share-picker
}
The portal reads the file when it starts: restart it with systemctl --user restart xdg-desktop-portal-hyprland, or log in again.
When Mochi isn’t running, or the share module isn’t enabled, mochi share-pick opens the portal’s own picker, so sharing never breaks.
The bubble needs Hyprland, which reports captures on its event socket.
Actions
| Action | What it does |
|---|---|
pick <remember> [windows] | Asks what to share and prints the portal’s answer; mochi share-pick runs it |
switch | Opens the picker to change what a switchable share copies; clicking the bubble does this |
cancel | Shares nothing |
The picker sends screen, window, region, back, area, remember and switchable itself.
Clipboard
Keeps what you copy, text and images, and pastes it back. mochi ipc clipboard toggle, bound to a key like SUPER+V, grows the island into a search over the history, pinned entries first, then the rest newest first. Typing searches the start of each text; images match “image”. A pane on the right shows the selected entry in full: the whole text, which Page Up and Page Down scroll, or the image scaled to fit. Enter puts the entry back on the clipboard and pastes it into the window you were in, by typing Ctrl+V for you, or Ctrl+Shift+V in a terminal. Shift+Enter only copies it. Ctrl+P, or the pin button on the selected row, pins or unpins it. Shift+Delete, or the trash button, removes it. Escape closes.
Mochi reads the clipboard through the ext-data-control-v1 Wayland protocol, which Hyprland and Sway support, and pastes through zwp-virtual-keyboard-v1. On a compositor without ext-data-control-v1, it uses the older wlr-data-control, which does the same; mochi doctor says which your compositor has. Starting mochid with MOCHI_DATA_CONTROL=wlr uses wlr-data-control even when both are there, to test it. It replaces cliphist and wl-paste --watch; nothing else needs to run.
Where the history lives
By default it stays in memory: a file in $XDG_RUNTIME_DIR/mochi, which is a tmpfs only you can read. It survives a restart of mochid and goes when you log out.
With storage = "disk", it’s kept in $XDG_STATE_HOME/mochi/clipboard/history, encrypted with XChaCha20-Poly1305. The key is made on the first start and kept in the Secret Service, as “Mochi clipboard history key”: gnome-keyring, KeePassXC, or anything else that implements it. Without the key the file can’t be read. When no Secret Service answers, Mochi keeps the history in memory instead and says so on the control center card. It never writes it to disk unencrypted.
Either way:
- Copying the same thing again moves its entry to the top instead of keeping it twice.
- Removing an entry, or clearing the history, rewrites the file at once, so nothing of it stays behind.
- The file is readable by you only, and text is compressed with zstd.
Pins
A pinned entry stays at the top of the picker and of the control center page, under “Pinned”. Clearing the history leaves it, and it doesn’t count toward max_entries or max_age_hours. Pins are kept in $XDG_STATE_HOME/mochi/clipboard/pins, encrypted with the same key as the history on disk, even with storage = "memory", so they last across logouts. Mochi asks the Secret Service for the key when you pin the first entry, or at startup once pins exist. When no Secret Service answers, pins stay in $XDG_RUNTIME_DIR until you log out, and the control center card says so. Copying a pinned entry again doesn’t add it to the history.
What isn’t kept
- Copies that password managers mark as secret, with the
x-kde-passwordManagerHinttype, are never read. KeePassXC marks passwords this way.skip_secrets = falsekeeps them. - Copies made while a window listed in
ignorehas the keyboard are never read. The list holds app ids, matched in any case; on Hyprland the app id is the window’s class, whichhyprctl activewindowshows. By default it lists KeePassXC, Bitwarden and 1Password. Mochi learns which window has the keyboard throughwlr-foreign-toplevel-management, which Hyprland, Sway and niri support; on other compositorsignorehas no effect. - Nothing is kept while the history is paused. A bubble shows on the island meanwhile; clicking it resumes.
The control center has a card with the number of entries and pins, a button to pause the history and one to clear it, and a Clipboard page with the pins and the history: search them, click an entry to paste it, or pin, copy or remove it from its row. The pin button shows on a pinned row, and on the others when you point at them. Clicking an image, here or in the picker, opens it in the card a screenshot gets, with copy, edit and delete; Enter still pastes it. An image row held and dragged onto another app drops the image there as a file, as from a file manager: into a chat, a browser or an editor. Shift+click or Ctrl+click selects several images, and dragging one of them drops them all. mochi ipc control-center open clipboard/history opens the page.
# Clipboard: keeps what you copy. `mochi ipc clipboard toggle`, bound to
# SUPER+V, opens the history; picking an entry pastes it.
[module.clipboard]
# Where the history lives. Memory keeps it in memory only you can read, so
# it goes when you log out. Disk keeps it in Mochi's state folder, encrypted with a key Mochi stores in the Secret
# Service (gnome-keyring, KeePassXC); without one it stays in memory.
# storage = "memory"
# The most entries to keep; the oldest go first.
# max_entries = 500
# Remove entries last copied more than this many hours ago. 0 keeps them
# until the history is full.
# max_age_hours = 0
# Copies larger than this many megabytes aren't kept.
# max_item_mb = 16
# The most entries the picker lists.
# max_results = 50
# Don't keep copies that password managers mark as secret with the
# x-kde-passwordManagerHint type. KeePassXC marks passwords this way.
# skip_secrets = true
# Don't keep anything copied while one of these windows has the keyboard,
# matched in any case against the app id, which is the class on Hyprland.
# It needs the compositor to tell which window has the keyboard, through
# wlr-foreign-toplevel-management: Hyprland, Sway and niri do; elsewhere
# this has no effect.
# ignore = ["org.keepassxc.KeePassXC", "Bitwarden", "1Password"]
# Paste a picked entry into the window you were in, by typing Ctrl+V for
# you. false only copies it.
# paste = true
# Window classes that paste with Ctrl+Shift+V instead: terminals.
# terminals = ["kitty", "foot", "footclient", "Alacritty", "com.mitchellh.ghostty", "org.wezfurlong.wezterm", "org.kde.konsole", "org.gnome.Console", "org.gnome.Ptyxis", "xterm"]
Actions
| Action | What it does |
|---|---|
toggle, open, close | Shows or hides the history |
pick <id> | Copies an entry and pastes it into the window you were in |
copy <id> | Copies an entry without pasting it |
copy-text <text> | Copies some text, and keeps it in the history; the launcher’s calculator and providers copy through it |
paste-text <text> | Copies some text and pastes it into the window you were in |
show <id> | Opens an image entry in the capture module’s preview card |
pin <id>, unpin <id> | Pins an entry, or puts a pin back in the history |
delete <id> | Removes an entry, pinned or not |
clear | Removes everything but the pins |
pause [on|off|toggle] | Stops keeping what you copy, or starts again; on without an argument |
resume | Starts keeping what you copy again |
The picker sends search and preview itself.
Tray
The icons apps put in a system tray, like Discord, Steam, Spotify or nm-applet. A tray bubble next to the island opens the drawer: every app’s icon and name on the island. Click an app to do what a click on its icon does, usually showing its window. Right-click it for its menu, drawn in Mochi’s style: entries with more open as a page of their own, and Escape or the back arrow goes up a level. The menu follows the app while it’s open: a checkmark the app flips, a label it renames or an entry it adds shows at once, on the page you’re on. A middle click does the app’s second action.
The keyboard works in the drawer too: the arrows move between the apps, Enter activates one, and Shift+Enter or the Menu key opens its menu. In a menu, Up and Down move between the entries, skipping separators, Enter or Right picks one, and Left goes back up. The app under the pointer or the arrows shows its tooltip under the apps, like Discord’s unread count; a pinned bubble shows it beside itself when the pointer rests on it.
Apps listed in pinned also get a bubble of their own, which takes the same clicks and the scroll wheel, the way some apps change the volume or the track. An app asking for attention makes its bubble, or the tray bubble, breathe in the accent color, and marks it in the drawer. Icons their app marks as passive, unimportant for now, stay in the drawer, dimmed.
# Tray: apps' tray icons, like Discord, Steam or nm-applet. A bubble opens
# the drawer with every app; a right click shows an app's menu.
[module.tray]
# Apps with a bubble of their own next to the drawer's.
# pinned = []
# Apps never shown.
# hidden = []
# Old X11 tray icons (XEmbed), like Wine's: Mochi starts KDE's
# xembedsniproxy for them when it's installed and not running already.
# xembed = true
[bubbles.tray] moves the bubbles, like any module’s.
How it works
Apps register their icons with a StatusNotifierWatcher over D-Bus, and Mochi reads the menu through DBusMenu. While a menu is open, Mochi listens for the app’s LayoutUpdated and ItemsPropertiesUpdated signals and reads the whole menu again after each burst of them. Mochi serves the watcher. Only one program can: if another tray already does, like Waybar’s, Mochi shows the icons that tray collects instead. Apps that only speak the old XEmbed tray, like Wine’s and some games, show through KDE’s xembedsniproxy, which turns their icons into StatusNotifierItems: Mochi starts it when it’s installed, an X server runs and no other copy does, and stops it with the module. xembed = false leaves it alone. Without it, those icons don’t show.
Icons come from the icon theme, from the app’s own icon folder, or from the pixels the app sends, which Mochi writes as PNG files in its runtime directory.
| Action | What it does |
|---|---|
toggle, open, close | Opens or closes the drawer |
list | Prints each app’s key, name and state |
activate <app> | Does what a click on the app’s icon does |
secondary <app> | Does what a middle click does |
scroll <app> <delta> [vertical|horizontal] | Scrolls on the app’s icon; 120 is one notch |
menu <app> | Opens the app’s menu on the island |
click <app> <entry> | Clicks an entry of the open menu |
<app> is the key list prints, usually the app’s id, or its name. The menu sends submenu itself, as a submenu opens, for apps that fill it only then.
Widgets
Widgets are small views on the desktop, under your windows, from any module or plugin. You can place as many as you like, the same one several times, each with its own settings, on any monitor.
Arranging them
mochi ipc widgets edit, or Arrange widgets on the Widgets page of the settings, brings the widgets over the windows on the focused monitor, dims the screen and shows the grid, and the island says “Arranging widgets”:
- Drag a widget to move it. It snaps to the grid.
- Drag its round corner handle to resize it, within the sizes it allows.
- While you drag or resize, thin accent lines show where the widget’s edges or middle line up with another widget’s edges or middle, or with the middle of the screen. Within 6 pixels of such a line, the widget snaps to it instead of the nearest grid cell. Positions are saved as whole cells from the widget’s anchor, so it only snaps to lines it can be saved on: a widget whose middle is in the middle third of the screen counts its cells from the screen’s middle, so it can center on the screen but not always line up its edge with a widget on the left.
- Click it, or its pencil, to open its settings, a form made from the settings it declares. Changes apply at once. Its trash button removes it.
- With more than one monitor, its settings end with a choice of monitor, left to right. Pick another to send the widget there: it keeps its anchor and its offsets, moved in only as far as it takes to stay on that screen, and arranging moves to that monitor with the widget’s settings open.
- A widget with several looks, like a clock that can be digital or stacked, has them at the top of its settings. A new look comes at its own size, from the same anchor.
- Where widgets overlap, the one on the higher layer is on top. The arrows over a widget move it a layer up or down.
- The drawer, a panel down the left side of the screen, opens as arranging starts, unless a widget’s settings open with it. While it’s closed, the island’s notice has an Add widgets button: a click on the notice opens it again. It goes on the right when the island sits on the left, so the island’s notice stays clear. Its close button or Escape closes it. It has three tabs:
- Add: every look of every widget the running modules and plugins offer, as cards with a live preview, the widget’s own view with its real data, a line on what it shows, and how many are on the desktop already. A search box and a chip per category narrow the list. Click a card to put it in the first free spot on this screen, clear of the panel and the island, or drag it onto the screen to put it there; the panel slides away while you drag.
- On desktop: every widget placed, on every monitor, with where it is. Its pencil opens its settings, on the monitor it’s on, and its trash button removes it.
- Layouts: arrangements saved under a name, to show on a workspace, a screen or every screen. See Saved layouts.
- Copy, at the bottom of the drawer, copies the layout as
widgets.toml; its arrow has “Copy as Nix”, for home-manager. - Done stops arranging. So does Escape, once the drawer is closed.
Tab moves through the drawer’s search, chips and cards, and Enter or Space adds the card that has the focus; the arrow keys switch the tabs while they have it.
Bind it to a key, like the other panels:
hl.bind("SUPER + W", hl.dsp.exec_cmd("mochi ipc widgets edit"))
widgets.toml
The layout is in widgets.toml, next to config.toml. Arranging rewrites it after every change, and changes you make to it by hand apply as soon as you save it; a file that doesn’t read is logged, and the widgets stay as they were. mochi config check checks it.
layout = "Work" # the saved layout this is, if any
[[widget]]
id = "w1" # its own, made when it's added
module = "widgets" # the module offering it
widget = "clock" # which of its widgets
variant = "digital" # which of its looks; the first when left out
output = "DP-3" # the monitor
anchor = "top-right" # the point it's placed from
x = -2 # grid cells from that point
y = 3
width = 14 # in grid cells
height = 7
z = 1 # its layer, 0 when left out: higher is on top
[widget.settings]
timezone = "Asia/Tokyo"
seconds = true
A widget’s anchor point sits at the same point of the screen, moved by x and y cells: a widget anchored bottom-right with x = -2 stays two cells from the right edge on any screen size. The anchors are top-left, top, top-right, left, center, right, bottom-left, bottom and bottom-right. Arranging picks the anchor of the third of the screen a widget’s middle is in.
A widget whose module isn’t running, or whose monitor isn’t connected, waits in the file until it is. One whose variant its widget no longer offers gets the first look.
Saved layouts
The drawer’s Layouts tab keeps the widgets of a screen under a name, like one for work and one for the evening, and shows each where you want it: the same on both screens, or one per screen, or one per workspace.
Type a name and press Save, or Enter: the widgets this screen shows are kept under that name, and that layout shows on this screen from then on, so the changes you make here go to it. The other screens go on showing what they did, so saving on each screen gives each its own layout. Saving under the name of the layout already shown here only keeps it. The trash button deletes a saved layout, after a second click on Delete.
Apply to
Each layout has Apply to, which lists where it can show, each with a switch:
- Every screen: every screen and workspace, unless something closer is on.
- Each screen, like
DP-3: all its workspaces. Turn it on for both screens to have the same widgets on both. - Each workspace of a screen, as a chip under it, like “Workspace 2”: only that workspace there. Each workspace can have its own widgets.
A layout can show in as many places as you like, and turning one on puts it there in place of the layout that showed there. The closest one wins: a workspace’s, then a screen’s, then every screen’s. Where none is on, the screen shows widgets.toml’s own widgets, the arrangement from before saved layouts, each on the monitor it names. Switching workspace switches the widgets with it.
A layout shown in several places is one layout, linked: moving a widget, changing its settings or adding one on one screen changes it on the others too. A layout saved from one screen is the same on every screen it shows on. One arranged across several, from before, keeps each widget on its own screen. Sending a widget to a screen that shows another layout moves it into that layout.
The top of the tab says what this screen shows and where, and “Stop showing it” goes back to what shows here without it. Deleting a layout stops showing it everywhere it was shown.
Where a layout shows is in widgets.toml, as [[show]] entries:
[[show]]
layout = "Work" # every screen
[[show]]
layout = "Music"
output = "DP-3" # every workspace of DP-3
[[show]]
layout = "Coding"
output = "DP-3"
workspace = "2" # workspace 2 on DP-3
An entry with a workspace and no output is for that workspace on any screen. Workspaces go by the name the compositor gives them, like 2, and Apply to lists the ones the compositor has, with the one each screen shows. An entry naming a layout that isn’t saved is passed over.
Each saved layout is a file in widget-layouts/, next to widgets.toml, like widget-layouts/Work.toml, in the same form as widgets.toml. Copying one into another machine’s widget-layouts/ brings it there. A widget keeps its id in every layout it’s saved in, so a note saved in two layouts is the same note, and removing a widget keeps its content while a saved layout still has it.
mochi ipc widgets use-layout <name> still puts a saved layout in place of widgets.toml’s own arrangement, each widget on its own monitor. An arrangement without a name that isn’t saved already is kept as “Unsaved” then, so it never loses widgets.
With home-manager
programs.mochi.widgets declares a layout, as a list like mochi ipc widgets export prints, or as the text of a widgets.toml:
programs.mochi.widgets = [
{
id = "w1";
module = "widgets";
widget = "clock";
output = "DP-3";
anchor = "top-left";
x = 2;
y = 4;
width = 16;
height = 8;
settings.seconds = true;
}
];
It’s written as a file Mochi can change, not a link into the store, so arranging keeps working. A rebuild writes it again only when the declared layout changed, so what you arranged survives other rebuilds. To keep an arrangement for good, use “Copy as Nix” while arranging, or mochi ipc widgets export, and paste it in place of the old layout.
# Widgets: views from any module on the desktop, under the windows. Where
# they are is in widgets.toml next to this file; `mochi ipc widgets edit`
# arranges them.
[module.widgets]
# The size of a grid cell, in pixels. Widgets snap to it, and widgets.toml
# counts in cells.
# grid = 16
# Let plugins' widgets go on the lock screen too. Like every widget there,
# they never get a key and can't unlock; they only show, and their buttons
# do nothing but play, pause and skip.
# lock_plugins = false
The widgets
| Widget | module, widget | Settings |
|---|---|---|
| Clock | widgets, clock | Looks: digital, the time over the date; stacked, the hour over the minutes; analog, hands and ticks; shape, the time inside a shape in the accent color; minimal, the time and the date on one line, without a card; world, the time in a few cities. timezone (like Europe/Paris; empty for this computer’s), hours ("24" or "12"), seconds (digital and analog), date (digital, stacked and minimal), zones (world), shape (none, cookie, circle, pentagon, clover, burst, hexagon, octagon, squircle or pill: a cookie on the shape look, none on digital and stacked, which can sit in one too) |
| Calendar | widgets, calendar | Looks: month, this month as a grid, with arrows to the months around it; week, this week on a strip. Today is a pentagon in the accent color. first_day (monday or sunday) |
| Focus timer | timer, focus | The timer’s time left in a ring, with pause and stop, or Start focus when nothing runs |
| To-do | notes, todo | title, done (show or hide the done items). Click an item to tick it; type into the bottom field and press Enter to add one |
| Note | notes, note | title. Click it and type; it saves a moment after you stop |
| Now playing | media, now-playing | Looks: card, the control center’s card, the cover beside the track and the controls; artwork, a tall card with the cover big, the track, the progress and the controls under it; cover, only the cover, without a card, with a button to play or pause. It steps aside while no player has a track |
| Battery | battery, level | Looks: card, the control center’s card, with the power profiles and the peripherals’ batteries; ring, the level as a ring, and whether it’s charging and how long until full or empty. The card steps aside without a battery or a peripheral with one, the ring without a battery |
| Performance | performance, graphs | Looks: graphs, each reading with its last two minutes; rings, CPU, memory and disk as rings; meters, a bar for CPU, memory, GPU and disk, with what each uses. The disk is the one your home directory is on. For the graphs, cpu, memory, gpu (on unless set off), disk, network (off unless set on): which readings show. An older widget with reading set to one reading in widgets.toml shows only that one until you remove the line |
| System info | performance, system | The distribution, the kernel, the uptime, Mochi’s version, the compositor, the CPU and the memory in use, as many lines as fit |
| Palette | colors, palette | The latest colors you picked, as many as fit. Click one to copy it, hover it to see it |
| Weather | weather, current | Looks: current, the weather now with the place; icon, the sky’s icon in a cookie with the temperature beside it; forecast, the next days with their low and high; hours, the next 12 hours as a curve. It says how to set a place until one is set |
The world clock’s zones are names like Europe/London, with commas between them, up to four; in widgets.toml they can be a list too. While you type in its field, or in a clock’s timezone, a menu under it lists the system’s zones that match what follows the last comma, like “Tokyo, Asia” with “UTC+9 · Japan”, with the same search as the clock’s World tab: a city, a country or an offset like utc+9. A click, or Up, Down and Enter, puts one in. Quickshell has no time zone database, so the module asks the system for each zone’s offset from UTC, with date, and again every ten minutes, so a change to daylight saving shows within ten minutes. A zone the system doesn’t have says so on its line. Each line says how far ahead of this computer the city is, and “Tomorrow” or “Yesterday” when its date isn’t today’s here.
The minimal clock has no card: a soft halo in the island’s background color sets it apart from the wallpaper. With software rendering, which has no effects, it shows without the halo.
Each to-do list and note keeps its own content, in the notes module. Typing into one gives the desktop the keyboard until you click a window; Escape lets go of the field.
Actions
| Action | What it does |
|---|---|
edit [on|off|toggle] [output] [id] | Starts or stops arranging, on the focused monitor or the one named, with a widget’s settings open |
edit-lock [on|off|toggle] [output] [id] | The same for the lock screen’s widgets |
add <module> <widget>[:<variant>] [output] [anchor] [x] [y] | Places a widget, in a look like clock:digital or its first; prints its id. Without an anchor, in the first free spot, down the left edge first |
variant <id> <variant> | Gives one another look, at that look’s size |
move <id> <output> <anchor> <x> <y> | Moves one |
resize <id> <width> <height> | Resizes one, in cells, within its limits |
set <id> <setting> <value>, reset <id> <setting> | Changes one of its settings, or puts it back to the default |
remove <id> | Removes one |
layer <id> up|down|front|back | Moves one a layer up or down, or over or under all the others |
drawer [on|off|toggle] | Opens or closes the drawer while arranging |
save-layout <name>, delete-layout <name> | Keeps the widgets the screen shows under a name and shows that layout there, or deletes a saved layout |
show-layout <place> <name> | Shows a saved layout on a place: everywhere; a monitor, like DP-3; a workspace on it, like DP-3/2; a workspace on any monitor, like */2; or screen and workspace, the monitor being arranged on or the focused one, and its workspace |
hide-layout [place] | Stops showing the layout set for a place, or the one shown on the screen |
use-layout <name> | Puts a saved layout in place of widgets.toml’s own arrangement |
layouts | Prints the saved layouts |
export [nix|toml], copy [nix|toml] | Prints the layout, or copies it |
The desktop layer sends screen <output> <width> <height> [left] [right] [top] [bottom] itself: each monitor’s size, and what the drawer and the island cover, for finding free spots.
Modules and plugins offer widgets of their own: see Writing widgets.
Notes
To-do lists and notes, as desktop widgets. Each one you place has its own content, kept in $XDG_STATE_HOME/mochi/notes.json under the widget’s id, and removing the widget drops it.
The widgets are typed into on the desktop: click the to-do list’s bottom field or the note, and type. The to-do list adds an item on Enter; a click on an item ticks it, its cross removes it, and “Clear done” removes the ticked ones. The note saves a moment after you stop typing.
# Notes: to-do lists and notes as desktop widgets. Each one you place has
# its own content, kept in $XDG_STATE_HOME/mochi/notes.json.
[module.notes]
| Action | What it does |
|---|---|
add <widget> <text> | Adds an item to a to-do list |
toggle <widget> <index>, delete <widget> <index> | Ticks or removes an item, counting from 0 |
clear <widget> | Removes the ticked items |
write <widget> [text] | Replaces a note’s text |
forget <widget> | Drops what a widget kept; the widgets module sends it when one is removed |
Emoji
An emoji picker. mochi ipc emoji toggle, bound to a key, grows the island into a grid of emoji: a search box at the top, a tab for the emoji you picked last and one per Unicode group, and the group’s emoji below. Typing searches every emoji by name, like “cat face” or “thumbs”; every word has to start a word of the name or of its group.
The arrows move the selection, even while you type, and Tab or Shift+Tab changes the tab. Enter pastes the selected emoji into the window you were in, and Shift+Enter only copies it. A click pastes, and a right click or Shift+click copies. The emoji under the pointer has its name at the bottom. Escape closes.
Pasting and copying go through the clipboard module, which types Ctrl+V for you. Without it, the picker can still copy when wl-copy is installed, but it can’t paste.
The emoji you pick are kept in $XDG_STATE_HOME/mochi/emoji.json, most recent first. They fill the Recent tab, and they rank a little higher in searches.
In Hyprland:
hl.bind("SUPER + period", hl.dsp.exec_cmd("mochi ipc emoji toggle"))
Skin tones
The six swatches next to the search box set the skin tone of every emoji of a person or a hand: none (the yellow ones), then the five Fitzpatrick tones from light to dark. The tone applies in the grid, in the Recent tab and in the launcher.
To give one emoji a different tone, hold it down for a moment. Its six forms open over it; a click pastes one, a right click copies it, and that emoji keeps that tone from then on, whatever the default. Escape or a click elsewhere closes them without picking. Emoji with tones have a small dot in the corner when the pointer is on them.
Emoji of two people, like “people holding hands” or “kiss: woman, man”, take the same tone for both. Unicode also has them with a different tone for each person; the picker leaves those out. Families have no tones in Unicode.
The tones are kept in emoji.json with the recent emoji.
In the launcher
The module adds a provider to the launcher: type : and a few words, like :fire. Enter pastes the emoji, and Shift+Enter copies it. With nothing after the :, the emoji you picked last come first. Change the prefix in a [module.launcher.providers.emoji] section.
# Emoji: an emoji picker. `mochi ipc emoji toggle`, bound to a key, opens a
# grid on the island; `:` in the launcher searches them too. The emoji you
# pick are kept in $XDG_STATE_HOME/mochi/emoji.json and come first, with the
# skin tones you set in the picker.
[module.emoji]
# How many recently picked emoji to remember. They fill the Recent tab,
# come first in the launcher before you type, and rank a little higher in
# searches.
# recent = 24
# The most results the launcher lists for an emoji search, at most 50.
# max_results = 50
Actions
| Action | What it does |
|---|---|
toggle, open, close | Shows or hides the picker |
paste <emoji> | Pastes an emoji into the window you were in, and remembers it |
copy <emoji> | Copies an emoji, and remembers it |
search [words] | Answers with the matching emoji as launcher results, one JSON line each |
pick <emoji> | Remembers an emoji as picked; the launcher sends this |
tone <tone> [emoji] | Sets the default skin tone: none, light, medium-light, medium, medium-dark or dark. With an emoji, sets that emoji’s own tone |
The table comes from Unicode’s emoji-test.txt, without the hair style variants. Each emoji that has skin tones lists its five toned forms. modules/emoji/data/generate.sh writes it again for a newer Unicode.
Colors
A color picker. mochi ipc colors pick, bound to a key, freezes every screen and shows a magnifier next to the pointer: the pixels around it, enlarged, with the one under the pointer outlined and its hex below. A click picks that pixel; Escape or a right click cancels.
hl.bind("SUPER + SHIFT + P", hl.dsp.exec_cmd("mochi ipc colors pick"))
The picked color is copied in the format setting’s format, kept in the history, and shown on the island for 8 seconds: a big swatch and a row for each format.
| Format | Example |
|---|---|
| HEX | #1e1e2e |
| RGB | rgb(30, 30, 46) |
| HSL | hsl(240, 21%, 15%) |
| OKLCH | oklch(24% 0.03 284) |
Clicking a row copies it in that format. With the clipboard module enabled, copies go through it, so they’re in its history too; without it, Mochi runs wl-copy.
The color is the exact pixel on the screen, also with fractional scaling. When the picker opens, Mochi copies every monitor through wlr-screencopy, which Hyprland and Sway support, and reads the pixels from that copy. The pointer’s position is turned into the monitor’s own pixels, so on a 1.5 scale the pixel picked is the one the pointer is over, not a blend of its neighbors.
The history
The colors you pick are kept in $XDG_STATE_HOME/mochi/colors.json, newest first. Picking a color again moves it to the top, and only the newest history stay.
The control center has a Colors card with the last 8 colors as dots: hover one to see it in the default format, click it to copy it. Its Pick button closes the control center and opens the picker. The Colors page lists the whole history, each color with its four formats as buttons that copy them and a trash button that removes it, with “Pick a color” and “Clear” above. mochi ipc control-center open colors/history opens the page.
On the desktop
The Palette widget shows the latest colors as swatches, newest first, as many as fit: a bigger widget shows more. Hover a swatch to see it in the default format, click it to copy it. Its pick button opens the picker. Add it from the drawer while arranging widgets, or with mochi ipc widgets add colors palette.
In the launcher
Type # in the launcher. Alone, it offers “Pick a color from the screen” and lists the history. Followed by a color, it lists that color in every format; Enter copies the one you choose, Shift+Enter types it into the window you were in, and the color goes into the history. It reads:
- hex:
1e1e2e,#1e1e2e,#abc, or with transparency,#1e1e2e80 rgb(30 30 46),rgb(30, 30, 46)andrgba()hsl(240 21% 15%),hsl(240, 21%, 15%)andhsla()oklch(24% 0.03 284)- CSS color names, like
rebeccapurple
Anything else lists the colors in the history and the CSS names that start with it.
# Colors: a color picker. `mochi ipc colors pick` freezes the screen and
# shows a magnifier; a click copies the pixel's color and keeps it in the
# history, in $XDG_STATE_HOME/mochi/colors.json. `#` in the launcher lists a
# color in every format.
[module.colors]
# The format a pick copies: "hex", "rgb", "hsl" or "oklch". The island's
# card copies the others.
# format = "hex"
# How many colors the history keeps.
# history = 50
# Hex in capitals: #1E1E2E.
# uppercase = false
Actions
| Action | What it does |
|---|---|
pick | Opens the picker |
cancel | Closes the picker |
add <color> | Adds a color to the history |
copy <color> [format] | Copies a color, like #1e1e2e, in the default format or in hex, rgb, hsl or oklch |
remove <color> | Removes a color from the history |
clear | Removes every color from the history |
The control center sends start, the launcher search and pick-result, and the picker hover and select themselves.
Drop
Drag files onto the island. While they hover, its outline turns to the accent and it says to drop them. Once dropped, it names what came, like “3 PDFs” or “report.pdf”, and offers what fits:
| Action | For | With |
|---|---|---|
| Compress | anything | zip, or bsdtar |
| Extract | zip, tar, tar.gz and other archives, 7z, rar | bsdtar, or unzip, tar and 7z |
| Merge PDFs | two PDFs or more, in the order dropped | pdfunite (poppler), or qpdf |
| Copy paths | anything | wl-copy |
| Open | anything, up to 10 files | xdg-open |
Under Convert to, a button for each format the files convert to:
| From | To | With |
|---|---|---|
| PNG, JPEG, WebP, GIF, BMP, TIFF | PNG, JPEG, WebP, GIF, BMP, TIFF, ICO | nothing: Mochi converts them itself |
| HEIC, AVIF | the same | ImageMagick (magick) |
| images | SVG, traced into shapes | vtracer |
| images | ImageMagick | |
| videos | MP4, WebM, MKV, GIF, MP3 (the sound) | ffmpeg |
| sound | MP3, Ogg, FLAC, WAV | ffmpeg |
| Word, Writer, Excel, PowerPoint files | PDF, Word, ODT, HTML | LibreOffice (soffice) |
| documents, Markdown, HTML | Markdown, Word, ODT, HTML | pandoc |
| archives: ZIP, 7z, tar and compressed tars, RAR to read | ZIP, 7z, tar, tar.gz, tar.xz, tar.zst | bsdtar (libarchive) for all of them; or unzip, tar and 7z to read and zip, tar and 7z to write, with gzip, xz and zstd for the compressed tars |
When videos are dropped, a row of video encoders sits under the formats: Auto, which lets ffmpeg pick, then the ones your ffmpeg has, like H.264, HEVC, AV1 and VP9 on the CPU, and NVIDIA’s or AMD’s when such a GPU is in the machine. The one picked goes to every conversion to a file it fits: H.264 in MP4 or MKV, VP9 in WebM; for the others ffmpeg picks. video_encoder sets the one it starts with.
A JPEG has no transparency, so transparent pixels land on white; an icon is at most 256 pixels a side. An archive converts by extracting into a scratch folder next to it and packing that again, so the new one holds the same files and folders; the scratch folder goes once it’s done, or when you stop it.
While an action runs, a bubble next to the island shows what the files are and a ring that fills as it goes, from ffmpeg’s own progress for videos and sound; the panel can close meanwhile. Resting the pointer on the bubble says what it’s doing and how far, and a click opens the panel again. There, Stop, or mochi ipc drop stop, ends it: the program it runs is killed, and what it made, finished or half written, is removed. The dropped files are never touched. When it finishes with the panel closed, the island says how it went.
When something dropped needs a program that isn’t installed, the panel says which, like “Install ffmpeg to convert videos”, and the other files still convert: an image and a video dropped together still offer GIF for the image.
An action shows only when a program for it is installed; mochi doctor lists the ones missing. New files go next to the first dropped one, and never over an old one: a second Archive.zip becomes Archive 2.zip, and an archive extracts into a new folder named after it. After an action, the island says what it made, with Show to open its folder, and closes a few seconds later. Escape closes it sooner.
# Drop: files dragged onto the island. It names what came and offers the
# actions that fit.
[module.drop]
# The video encoder conversions start with, like "libx264", "libsvtav1" or
# "h264_nvenc" for NVIDIA's; Default lets ffmpeg pick. The panel lists the ones
# your ffmpeg has, and one that doesn't fit the file, like H.264 in WebM,
# gives way to ffmpeg's pick.
# video_encoder = ""
# The actions to offer: zip (with zip or bsdtar), extract (bsdtar, unzip,
# tar or 7z), merge for PDFs (pdfunite or qpdf), convert, copy for the
# paths (wl-copy) and open (xdg-open). Images convert between PNG, JPEG,
# WebP, GIF, BMP, TIFF and ICO in Mochi itself; to SVG with vtracer, and
# HEIC, AVIF and images to PDF with ImageMagick. Videos and sound convert
# with ffmpeg, documents with LibreOffice, Markdown and HTML with pandoc,
# and archives between ZIP, 7z and the tars with bsdtar, or unzip, tar, zip
# and 7z.
# actions = ["zip", "extract", "merge", "convert", "copy", "open"]
mochi ipc drop files takes paths or file:// URIs, one a line, to do the same from a script:
mochi ipc drop files "$(printf '%s\n' "$PWD"/*.pdf)"
mochi ipc drop run merge
Clock
A panel on the island with five tabs: Today, Calendar, Timer, Stopwatch and World. mochi ipc clock toggle, bound to a key, opens and closes it; mochi ipc clock open calendar opens it on a tab, or switches to that tab while it’s open. The control center has the same tabs as its Clock page. Opening it closes the other panels, like the launcher or the control center, and Escape closes it.
The keyboard reaches everything: Tab goes through the controls and the navbar, 1 to 5 pick a tab, Left and Right move along the navbar, and Enter or Space press what has the focus. In the calendar’s month, the arrows move the picked day, Page Up and Page Down turn the month, Home goes back to today, and Enter goes to the field for a new reminder.
To open it with a click on the idle clock instead of the control center:
[module.idle]
click = ["clock", "toggle"]
Today
The time big inside a shape in the accent color, with the date above it and a greeting under it. shape picks the shape: a cookie by default, or a circle, pentagon, clover, burst, hexagon, octagon, squircle or pill, or none for the time alone in the text’s color. With seconds on, the seconds sit under the minutes. day_progress shows how far through the day it is: a thin line under the date with the share beside it, a ring around the shape, or neither. Beside it, the weather from the weather module: the sky and the temperature now with the place and today’s low and high, the temperature it feels like, the humidity, the wind and the UV index, then the next 8 hours and the next 5 days. Until a place is set, it says so, and Set a place opens the setting; with the weather module off, a button opens its settings.
Along the bottom, the next reminder and when it’s due, or the oldest one still due, with Done. Add a reminder opens the calendar on today with the field ready.
Calendar and reminders
A month, today in an accent pentagon and a dot under each day with reminders, a full one while one of them isn’t done. Picking a day lists its reminders on the right, by time: Done for one that’s due, and the bin to delete it. Under them, a time and a text add one to the picked day. The time takes 18:30, or 6:30 PM and 6 pm on a 12-hour clock.
When a reminder comes due, the island says so, with Snooze 10 min and Done. Left alone, the notice goes after a minute, and the reminder stays due on the Today tab and in the calendar until you mark it done. Reminders go by the wall clock, so one that came due while the computer slept comes up within seconds of waking, and one that came due while mochid wasn’t running comes up when it starts, with how long ago it was due.
$XDG_STATE_HOME/mochi/reminders.json keeps them, done ones too, so the calendar still shows them. Each has a number, which the actions take:
mochi ipc clock remind tomorrow 19:30 "Ana's birthday dinner"
mochi ipc clock remind 2026-10-21 09:00 Dentist
mochi ipc clock reminders # every one, with its number
mochi ipc clock reminders tomorrow # one day's
mochi ipc clock done 3
mochi ipc clock delete 3
Timer
On the left, the focus timer’s countdown in a ring that waves while it runs, with lengths to start focus or a break, and pause, resume and stop while one runs. On the right, the timer module’s custom timers: a field that starts one from what you type, like 15m Tea, 90s or 1h 30m, a button for each of its presets, and each running timer with its time left, when it ends, “+1 min”, pause and stop. Start stays greyed out, with a hint under the field, until what’s typed begins with a length. The timer module does the counting, so its bubbles and its notices work as always. With the timer module off, the tab says so and opens its settings.
Along the bottom, the alarm every timer plays: a slider for its volume, which Left and Right move 5% at a time and a double click puts back to 80%, the sound’s name, Choose… to pick another file with the desktop’s file chooser, Default to go back to the sound theme’s alarm, and Play it. Each change goes to the timer’s settings through the settings module and applies at once, as on the timer’s page in the settings. With sound_command set, its player keeps its own volume, so the slider gives way to a line that says so. When no file chooser can open, the row says why, until its close button or the next change.
Stopwatch
The time to the tenth of a second, or the hundredth with precision = "hundredths", with Start, Lap, Pause and Reset. On the right, the laps, newest first: how long each took next to its number, the time at the end of it, and the fastest and the slowest marked. The clock module keeps the stopwatch, so it runs on with the panel closed and through a restart of mochid, like after an update; logging out forgets it. It keeps up to 99 laps.
Reset keeps the run: Runs beside Laps lists the past ones, newest first, with when each ended, its time and how many laps it had. history sets how many it keeps, 10 by default and up to 50, or 0 for none; $XDG_STATE_HOME/mochi/stopwatch-runs.json keeps them, so they outlast a logout. Copy hands the run going to the clipboard, with its laps, and the copy button on a past run hands over that one; Clear forgets them all. Copying goes through the clipboard module, or wl-copy when it’s off:
Stopwatch, 2026-10-09 23:47: 0:02.6
Lap 1 0:01.3 0:01.3
Lap 2 0:00.8 0:02.1
World
The time here, then in each of the zones, two to a row: the city, whether it’s yesterday, today or tomorrow there, how many hours ahead or behind it is, and the time. The zones’ offsets come from the system’s time zone database, read again every 10 minutes for daylight saving, as for the world clock widget. A zone the system doesn’t have says so.
Add a city lays every zone the system has over the cards, with a search: each as its city and region, with its offset now and its country under it, like “Tokyo, Asia” and “UTC+9 · Japan”. Before you type, it lists the zones on the tab, checked, then common cities from Honolulu to Auckland, then every zone west to east. A search finds a city, a region, a country or an offset, like tok, buenos aires, japan or utc+9, cities that start with it first; accents don’t matter, so sao finds São Paulo. A click adds a zone, or takes off one that’s there; with the keyboard, Down and Up move through the list and Enter does the same to the zone marked, which a search puts on its first match. Once the tab has its 8, the others dim and the heading says to take one off first. Escape or Done goes back to the cards.
The picker writes the zones setting, as the settings panel does, and Change the zones opens it there, where the same picker lists the zones, and a zone’s name the list doesn’t have can be typed. The clock module reads the system’s zones only while the picker is open, since there are a few hundred; mochi ipc clock zone-picker on tokyo opens it on the World tab with a search typed.
In the control center
With the control center on, the clock gives its home the Today card: the time, large, with the weekday and the date beside it. While the stopwatch has time on it, the stopwatch shows there instead, with a button to pause or resume it, and a reminder due within a day shows with when it’s due. Without the clock module, the control center has no time card; control-center/clock in its order or hidden becomes clock/clock. Its heading opens the Clock page, which has the panel’s Today, Calendar, Stopwatch and World tabs, the same views, on a row at the top. The focus timer has a card of its own there.
Credit
The seconds and the day’s progress on Today, the stopwatch’s tenths and past runs, copying a run, and the list of cities come from mochi-clock, a plugin by Xonex5. The bottom of the clock’s page in the settings says so, and See repo there opens it.
| Action | What it does |
|---|---|
toggle | Opens the panel on the tab setting’s tab, or closes it |
open [tab] | Opens the panel, on today, calendar, timer, stopwatch or world; switches tabs while it’s open |
close | Closes the panel |
remind <date> <time> <text> | Adds a reminder; the date is like 2026-10-21, today or tomorrow, the time like 19:30 |
reminders [date] | Prints every reminder, or a day’s, with its number |
done <id> | Marks a reminder done, so it doesn’t come up again |
snooze <id> [minutes] | Brings a reminder up again in 10 minutes, or the minutes given |
delete <id> | Deletes a reminder |
stopwatch <what> | start, pause, toggle, lap or reset the stopwatch, or status to print its time and laps; reset keeps the run |
runs | Prints the stopwatch’s past runs, with their numbers |
copy-run [run] | Copies the run going with its laps, or a past one by its number |
forget-run [run] | Forgets a past run, or all of them |
add-zone <zone>, remove-zone <zone> | Adds a time zone like Europe/Paris to the World tab, or takes one off, in the zones setting |
zone-picker <on|off> [search] | Opens the World tab’s zone picker, with a search typed, or closes it; the World tab shows it while the panel is on that tab |
# Clock: a panel with today, a calendar with reminders, the focus timer, a
# stopwatch and world clocks. Bind mochi ipc clock toggle to a key.
[module.clock]
# The tab it opens on: "today", "calendar", "timer", "stopwatch" or "world".
# tab = "today"
# The time zones on the World tab, up to 8.
# zones = ["Europe/London", "America/New_York", "Asia/Tokyo"]
# A "24" or a "12" hour clock.
# hours = "24"
# The day weeks start on in the calendar: "monday" or "sunday".
# first_day = "monday"
# Show the seconds on the Today tab.
# seconds = false
# How far through the day it is, on the Today tab: a "line" under the date,
# a "ring" around the clock, or "none".
# day_progress = "line"
# The shape the Today tab's clock sits in: "cookie", "circle", "pentagon",
# "clover", "burst", "hexagon", "octagon", "squircle", "pill" or "none".
# shape = "cookie"
# The stopwatch to the "tenths" of a second, or the "hundredths".
# precision = "tenths"
# How many of the stopwatch's past runs to keep, up to 50; 0 keeps none.
# history = 10
# Seconds a reminder's notice stays on screen. A reminder nobody marked done
# stays due on the Today tab and in the calendar.
# notice_seconds = 60
Every setting applies at once, without closing the panel.
Focus timer
A focus timer, after the pomodoro technique: 25 minutes of focus, then a 5-minute break, and a 15-minute break after every fourth session. Start it from its card in the control center, or with mochi ipc timer start, which you can bind to a key. Custom timers run beside it, like a kitchen timer’s: several at once, each with a label.
Inspired by mochi-clock by Xonex5: custom timers, their natural lengths, the alarm and the launcher’s :t come from it. The bottom of the timer’s page in the settings says so, and See repo there opens it.
While it runs, a bubble by the island counts down: a ring that empties as the time goes, with the minutes left inside it, in the accent color for focus and in green for a break. Rest the pointer on it for the time to the second. A click pauses it or resumes it. With wide = true in [bubbles.timer], the bubble shows the time to the second, like 18:42.
When focus ends, the island says so and offers the break, with Start the break and Done. With auto_break = true the break starts by itself and the notice says so, with Skip the break to go straight back to focus. When a break ends, the island offers the next session. The card in the control center has the time left with pause and stop, or Start when nothing runs. The desktop has a focus timer widget: the time left big inside a ring that waves while it counts down, with pause and stop, or Start focus when nothing runs.
The timers carry on when mochid restarts, like after an update, and changing the settings doesn’t stop them: the new lengths apply from the next phase. A phase or a timer that ran out while the computer slept ends as soon as it wakes. Logging out forgets them.
Custom timers
mochi ipc timer add 15m Tea starts a 15-minute timer labelled Tea. A length is written the way people type it: 5m, 90s, 1h 30m, 1h30, 1.5h, 2 min 30 sec, 10:00 or 1:30:00, or a bare number of minutes like 25. Whatever follows the length is the label. A number without a unit after one with a unit takes the next unit down, so 1h 30 is an hour and a half. Up to 20 run at once, each up to a day.
The clock panel’s Timer tab lists them with their time left and when each ends, with “+1 min”, pause and stop, and has a field to start one and a button for each of presets. The launcher starts them too: see below.
Each running timer has its own bubble, in the text color so it stands apart from the focus session’s accent, side by side in one pill. Its last minute counts in seconds. A click pauses or resumes that timer; with wide = true the bubble shows the label and the time to the second. timer_bubbles = "soonest" shows one bubble instead, for the timer that ends first, with how many more run. Settings › Bubbles hides the timer’s bubbles altogether.
When a timer runs out, the island says so with its label, and offers Again, “+1 min” and Done. The alarm plays, alarm-clock-elapsed from the sound theme or your sound_file, at volume, through pw-play or paplay, or canberra-gtk-play for the theme’s sound; sound_command plays it with a program of your own. Music or a video playing pauses, through the media module, unless pause_media = false. The timer’s page in the settings has a button that plays the alarm, to try the volume and the file, and Choose… beside sound_file picks the file with the desktop’s file chooser, showing sound files. The clock panel’s Timer tab has the same along its bottom: the volume, the sound with Choose… and Default, and Play it. focus_sound = true plays it when a focus session or a break ends too.
In the launcher
After :t (with the space, so emoji like :tea still work), the launcher offers to start the timer you type: :t 10m Pizza starts a 10-minute timer labelled Pizza. With nothing typed it lists the running timers, to pause or resume, then presets. :t sw starts or pauses the clock’s stopwatch, and offers a lap while it runs or a reset when it’s paused. [module.launcher.providers.timer] changes the prefix, like prefix = "t ".
| Action | What it does |
|---|---|
start [minutes] | Starts a focus session, of focus_minutes or the minutes given |
break [minutes] | Starts a break, long or short by the sessions done, or of the minutes given |
pause [id], resume [id] | Pause the focus session, or carry on from where it paused. With a custom timer’s number from list, or all, that timer or all of them |
toggle [id] | Pauses or resumes, or starts a focus session when nothing runs. With a number, pauses or resumes that custom timer |
stop [id] | Stops the focus session, or a custom timer by its number, or all of them |
status | Prints the phase and the time left, or the sessions done |
add <length> [label] | Starts a custom timer, like add 15m Tea or add 1h 30m Bread |
extend <id> [length] | Adds extend_seconds, or the length given, to a custom timer or all |
list | Prints the custom timers, a line each: the number, the label and the time left |
test-sound | Plays the alarm |
# Focus timer and custom timers: a bubble counts down a focus session, a
# break or a timer of your own, and the island says when it ends.
[module.timer]
# Minutes of focus a session counts down unless you pick another length.
# focus_minutes = 25
# Minutes of rest after a focus session.
# break_minutes = 5
# Minutes of rest after a run of focus sessions, as many as set below.
# long_break_minutes = 15
# How many focus sessions come before a long break. 0 never takes one.
# sessions_before_long_break = 4
# Starts the break by itself when focus ends, instead of asking.
# auto_break = false
# Plays the alarm when a custom timer ends.
# sound = true
# A sound file for the alarm, like ~/sounds/bell.oga. Empty plays
# alarm-clock-elapsed from the sound theme.
# sound_file = ""
# How loud the alarm plays, from 0 to 100.
# volume = 80
# What plays the alarm instead of pw-play or paplay; the file goes last,
# and the volume above doesn't apply.
# sound_command = []
# Plays the alarm when a focus session or a break ends too.
# focus_sound = false
# Pauses the music or video playing when a custom timer ends, through the
# media module.
# pause_media = true
# The bubbles of custom timers: Each for one each, side by side, or
# Soonest for one, for the timer that ends first.
# timer_bubbles = "each"
# The seconds "+1 min" adds to a custom timer.
# extend_seconds = 60
# The lengths the clock panel's Timer tab and the launcher offer.
# presets = ["3m", "5m", "10m", "15m", "30m"]
# Seconds the notice at the end of a phase or a timer stays on screen.
# notice_seconds = 30
For 50 minutes of focus and 10 of rest, breaks starting by themselves:
[module.timer]
focus_minutes = 50
break_minutes = 10
auto_break = true
A quieter alarm of your own, one bubble for the custom timers, and the music left playing:
[module.timer]
sound_file = "~/sounds/bell.oga"
volume = 40
timer_bubbles = "soonest"
pause_media = false
Weather
The weather where you are, from Open-Meteo, which needs no account or key: the sky and the temperature now, the next 24 hours and the next 7 days. The control center has a card with the weather now, the place and a strip of the next hours, a page with all of it, and the desktop a Weather widget in four looks.
Nothing is sent until you set a place. Until then, the cards, the page and the widget say so, and their Set a place button opens the setting. A place Open-Meteo doesn’t know gets Change the place, and a fetch that failed Try again. Set place to a city or a town, like "Lyon", or "Lyon, France" or "Springfield, Illinois" for the one in that country or region. Mochi looks the name up once with Open-Meteo’s geocoding, and keeps where it is. Set latitude and longitude instead to skip the lookup: they count once both are set, and place then only names them on the card.
The forecast comes again every refresh_minutes, 30 by default. When a fetch fails, as before the network is up, the next try waits a minute, then two, then four, up to refresh_minutes; a place Open-Meteo doesn’t know waits for you to change it. $XDG_STATE_HOME/mochi/weather.json keeps where the place is and the last forecast, so after a restart the weather shows at once and comes again only when it’s due. A forecast older than six hours isn’t shown. Changing the settings applies at once, without a restart.
Open-Meteo gets the place’s name when it’s looked up, then its coordinates with each fetch, and nothing else. A bento you share leaves place, latitude and longitude out.
| Action | What it does |
|---|---|
refresh | Fetches the forecast now |
status | Prints the weather now and today’s low and high, like Lyon: 15°C, overcast, feels like 13°C; today 10°C to 16°C. Updated 9 minutes ago |
places <query> | Looks up places by name with Open-Meteo, for the settings’ place search, which lists what it found |
In the control center
The Weather card is two columns wide: the sky’s icon, the temperature, the sky in words and the place, with the next hours beside them, as many as fit. Weather now is the same in one column, without the hours. It’s spare: it waits under “More cards” until you put it on the home, with the pencil or mochi ipc control-center arrange. Keep either, or both; the pencil’s minus takes the other off.
A click on either card’s heading opens the Weather page, also in the navbar and at mochi ipc control-center open weather/page. At the top, the place, how old the forecast is while it’s stale, a button that fetches it again and one that changes the place. Then the weather now: the sky in a cookie, the temperature, the sky in words and today’s low and high, with what it feels like, the humidity, the wind and where it comes from, the UV index with the WHO’s word for it (Low, Moderate, High, Very high, Extreme), and today’s sunrise and sunset at the place. Beside it, the next 7 days as the Forecast look draws them, and under both, the next 24 hours as the Hours look’s curve. A value the forecast lacks is left out.
The widget’s looks
The drawer has the widget under Weather in four looks, and its settings switch between them. mochi ipc widgets add weather current:<look> places one.
| Look | Size | What it shows |
|---|---|---|
current, Now | 16 by 6 | The sky’s icon, the temperature, the sky in words, and the place with today’s low and high |
icon, Icon | 16 by 8 | The sky’s icon in a cookie in the accent color, with the temperature big beside it over the sky in words |
forecast, Forecast | 20 by 14 | A row a day from today, as many as fit: the weekday, the sky, the chance of rain or snow from 20%, and the low and high on either side of a bar. The bars share the week’s scale, so a warm day sits to the right; today’s has a dot at the temperature now |
hours, Hours | 24 by 10 | The next 12 hours as a curve, with each hour’s temperature over it and its sky and hour under it. The first is now, with a dot on the curve. Where the columns get narrow, every other hour has its labels |
Sizes are in grid cells, and every look grows with the widget. Without a forecast, each look says why, with the same button as the card. When the last fetch failed, or the forecast is older than stale_minutes, an hour by default, each look adds how old it is, like “Updated 2 hours ago”. It’s never less than twice refresh_minutes, so a forecast waiting for its next fetch doesn’t count.
The weather in other views
The module’s state has the whole forecast, so any view can show it: a plugin, a widget of your own, a clock or a lock screen. Views read it with Daemon.state("weather").
| Field | |
|---|---|
configured | Whether a place or coordinates are set |
loading | Whether a fetch runs |
error | Why the last fetch failed, or null |
next | When the next fetch is due, in seconds since the epoch, or null while one runs, while nothing is set, and after a place Open-Meteo doesn’t know |
units | metric or imperial |
unit | The units’ signs: temperature (°C or °F) and speed (km/h or mph) |
place | name, region, country, latitude and longitude, or null before the lookup |
updated | When the forecast came, in seconds since the epoch, or null |
stale_after | How old updated gets, in seconds, before the looks say how old it is: stale_minutes, or twice refresh_minutes when that’s longer |
timezone, utc_offset | The place’s time zone, like Europe/Paris, and its offset from UTC in seconds |
current | The weather now, or null before the first forecast: temperature, feels_like, humidity (%), wind_speed, wind_direction (degrees, where the wind comes from), uv_index, time |
hourly | The next hours, from the one that runs, up to 24: time (when the hour starts, in seconds since the epoch), hour (0 to 23, at the place), temperature, precipitation (the chance of rain or snow, %) |
daily | The next days, from today, up to 7: time (midnight at the place), date (like 2026-10-09), weekday (0 is Sunday), min, max, precipitation (%), uv_index, sunrise, sunset (seconds since the epoch) |
Temperatures and speeds are in the units set. Each of current, the hours and the days also has the sky: code, the WMO weather code, text, like “Partly cloudy”, icon, a Material Symbols name for Symbol, like partly_cloudy_day or clear_night, and kind, one of clear, partly, cloudy, fog, drizzle, rain, sleet, snow, storm or unknown. current and the hours have day, false at night, which the icons follow; the days’ icons are the day’s.
# Weather: the forecast from Open-Meteo, which needs no account or key.
# Nothing is sent until a place is set.
[module.weather]
# A city or a town: type its name and pick it from what Open-Meteo finds.
# place = ""
# Or where you are, which skips the lookup: north and east are positive.
# latitude = 45.76
# longitude = 4.84
# Metric for °C and km/h, Imperial for °F and mph.
# units = "metric"
# How often to fetch the forecast again, in minutes.
# refresh_minutes = 30
# How old the forecast gets, in minutes, before the weather looks say how
# old it is, as when the computer was offline. Never less than twice the
# refresh time above, so a forecast waiting for its next fetch doesn't count.
# stale_minutes = 60
# Until a place is set, the control center's weather cards say how to set
# one. Off, they stay hidden until then.
# prompt = true
Settings
A panel with every option: the theme, the island, the bubbles, which modules run, each module’s settings and each plugin’s. A change applies as you make it. Theme options apply while you drag. A module’s own options apply 400 ms after you stop, since the module restarts to read them. Its Bento pages install plugins, themes and whole setups from the registry, and share yours: see Bento.
mochi ipc settings open opens it, and mochi ipc settings open osd opens a section: a module’s id, themes, text, layout, motion, island, bubbles, modules or about. An option’s path, like theme.colors.accent, opens its section and points at it. The control center’s gear opens the panel at the page you’re on, and the launcher finds “Settings”, each section and each option by name.
Using it
- A dot marks an option you changed in the panel, and its section in the sidebar. Hovering the option shows a button that undoes the change, back to what your files say, and Reset in the header does it for the whole section. Double-clicking a slider does the same.
- Typing in the search box looks through every option’s name and description.
@modifiedlists the ones you changed in the panel. Up and Down move through the sidebar, Ctrl+F goes back to the search box, and Escape closes the menu, the editor, the search, then the panel. - The font options list the fonts installed, each drawn in itself, with a search; a font that isn’t installed shows in red.
- Time zones, like the clock’s
zones, pick from every zone the system has, with a search that finds a city, a country or an offset likeutc+9, the same picker as the clock’s World tab. Up, Down and Enter work in it, and a zone’s name the list doesn’t have can be typed. - A file, like the timer’s
sound_fileor the theme’swallpaper, has a field to type its path and Choose…, which opens the desktop’s own file chooser through the XDG desktop portal, showing only sound files or images where the option says so. Without a portal, or one without a file chooser,zenityorkdialogopens one; with none of them, the option says so and the field still takes a path. - Options whose values come from somewhere pick them from a menu with a search, and lists pick several: the apps installed, with their icons, for the clipboard’s ignored apps and terminals; the outputs and microphones for a recording’s audio; the tray’s apps for
pinnedandhidden; the players for media’signore; the control center’s cards for its order. Typing a value that isn’t there works too where it makes sense. A command, like the idle clock’s click, picks a module, then one of its actions with what it does, then each of its arguments on a row of its own: a menu for a choice, or for what Mochi knows, like the monitors, the control center’s pages, the audio devices, the apps or the settings’ sections; a switch for on and off; a field for the rest. Command lines, like the lock or the terminal, offer ready-made ones for the programs installed. - Every change applies at once and is kept, so what you see is what you get. When something else tries settings without keeping them, like
mochi ipc settings preview, a bar offers Keep, which makes them changes like any other, or Drop. A reload drops them too, and Copy leaves them out. - TOML shows the section as TOML, every option at its value, to edit by hand. Save checks it first and shows what’s wrong instead of changing anything. Options for which the panel has no control, like the launcher’s providers, are edited there.
- Copy gives everything that isn’t a default as Nix, the
settingsandthemeattributes of home-manager’sprograms.mochi, ready to paste. Copy as TOML givesconfig.tomlandtheme.tomlinstead.
About
The About page, at the bottom of the sidebar, says which Mochi runs and where: the version and build, the revision for a build from the source tree, Quickshell’s version, the distribution, kernel, architecture, processor and memory, the desktop and compositor with its screens, the modules and plugins that run, and the memory and uptime of mochid and of the processes it started. “Copy details” puts all of it on the clipboard as text, to paste into a bug report; “Report a bug” opens a new issue on GitHub. A value in red says something is wrong, like a plugin that failed or a Quickshell version Mochi doesn’t support.
Where changes go
The panel never writes config.toml or theme.toml, which home-manager keeps read-only. It keeps its changes in changes.toml next to them, and mochid lays that file over both every time it reads them. A change goes away by itself once your files say the same, so pasting what Copy gave you and switching leaves nothing behind. Until then the changes survive restarts. “Undo all changes”, at the bottom of the sidebar, drops them all.
When changes.toml has an option that no longer fits, after an update renamed it for example, mochid starts without the changes and logs why.
Actions
| Action | |
|---|---|
open [section], toggle, close | The panel. |
set <path> <json> | Sets an option, like set theme.colors.accent '"#30d158"'. null unsets it. |
reset <path> | Undoes the change to an option, or to each option of a section, back to what the files say. |
arrange <json> | Moves, sorts, shows or hides modules’ bubbles, as the bubble editor does: arrange '{"media": {"area": "left", "order": 0}}'. null puts a key back to the module’s own. |
discard | Drops every change. |
preview <path> <json>, keep, drop | Tries an option without keeping it, then keeps or drops what’s being tried. |
try <json> | Tries whole tables of settings, like {"config": {...}, "theme": {...}}, in place of what was being tried; mochi bento try sends it. |
bento-catalog [refresh], bento-plan <source>, bento-show <source> | Read Bento’s registry and what it installed, or say what installing something does; show opens the Discover page on it, as mochi://bento/ links do. See Bento. |
bento-add <source> [commit], bento-remove <id>, bento-update [id], bento-try <source>, bento-use <id|mine>, bento-share <dir> [theme or parts] [name], bento-parts | What the Bento pages’ buttons run, with mochid bento. bento-forget closes what a plan or a share shows. |
text <path>, edit <path> <toml> | A section as TOML, and replacing it. |
export [nix|toml], copy [nix|toml] | Prints, or copies, every option that isn’t at its default. |
about, about-copy | Read what the About page shows, and copy it as text for a bug report. |
open-link <page> | Opens repository, documentation, issue (a new issue on GitHub) or mochi-clock (credited by the clock and the timer) in the browser, with xdg-open. Nothing else opens. |
choose-file <path> | Opens a file chooser for a file option, like config.module.timer.sound_file, and sets the option to the file picked; prints the path, or nothing when the chooser was closed. Another one while it’s open takes its place. |
The settings module has no settings of its own.
Tour
A guided tour of Mochi. Each module shows its real views with made-up data, so nothing of yours appears on screen, and a caption says what it does and where to find it.
The first time Mochi starts, a notice on the island offers the tour: Take the tour, Later, which asks again next time, or Never. After an update, it offers a shorter tour of what’s new since your last one, and nothing at all when nothing you’d see changed. An update to a new series, like 0.1.2 to 0.3.0, shows that series’ new steps. A patch within one, like 0.1.0 to 0.1.2, brings no steps, so the tour shows its changelog instead, a card for each fix or change. A first tour shows neither. mochi ipc tour start runs it any time, as do “Tour” and “What’s new in Mochi” in the launcher and Take the tour on the tour’s page in Settings.
During the tour
- The island is paused: notifications, the volume and every other module’s notices wait, and their bubbles hide. They all come back when the tour ends.
- Every monitor dims, and the dim layer takes every click and key, so nothing behind it reacts. Your compositor’s own keybinds still work.
- The tour moves on by itself, a few seconds a step. Space or → goes on sooner, ← goes back.
- Escape asks whether to stop: Enter stops, Escape carries on. A stopped tour starts again from the same step next time.
- Steps that show a look of the island, like notch mode or the bottom edge, try it without saving it, and put yours back after.
A module that’s off gets a card saying so, and where to turn it on.
# Tour: a guided tour of Mochi, with made-up data in every view. It offers
# itself the first time Mochi starts, and after an update with what's new.
# `mochi ipc tour start` runs it any time, as does "Tour" in the launcher.
[module.tour]
# Offer the whole tour the first time Mochi starts.
# install = true
# After an update, offer a short tour of what's new since the last tour.
# updates = true
# How long a module's step shows before the next, in seconds; the tour's own
# cards take a bit more than half. Space goes on
# sooner.
# seconds_per_step = 4
$XDG_STATE_HOME/mochi/tour.json keeps the last release whose tour you saw, and where a stopped tour was.
Actions
| Action | |
|---|---|
start [all|new] | The whole tour, or what’s new since the last one; by default the one offered, or where it stopped. |
next, back | Moves through the steps. |
stop, continue, end | Asks whether to stop, carries on, or stops at once. |
later, never | Answers the offer. |
Steps from modules and plugins
Each module offers its steps as contributions to the tour, so the tour of a module lives with its code. A plugin can do the same in its manifest:
[[contributions]]
target = "tour"
kind = "step"
id = "now"
view = "Card"
title = "Weather"
icon = "wb_sunny"
order = 10
options = { chapter = "desktop", since = "0.1.0", place = "card", size = [280, 96], caption = "The weather where you are.", payload = { temperature = 18, sky = "clear" } }
| Option | |
|---|---|
chapter | island, panels, notices, desktop, capture or settings. |
since | The release that brought it: the tour of what’s new shows it to anyone whose last tour was before. A minor release, like 0.2.0: patches bring no steps. |
caption | One or two plain sentences. |
payload | The made-up data the view gets. |
place | island (the default), bubble, or a control center card or desktop widget framed at size. A bubble’s payload can name its area. |
properties | More properties the view takes, like a widget’s settings and instance. |
The view is loaded with interaction turned off, and only when the module runs.
Updates
Mochi looks for a new release on GitHub at start and every 12 hours. When there’s one, the island says so once for that version, with View, which opens the Updates page in the settings, and Skip. The page says whether this Mochi is the latest, how it updates, and what each newer release brings, from its changelog. Check now looks again.
How it updates depends on how Mochi was installed, which the page finds by itself:
| Installed with | What the page offers |
|---|---|
| The install script | Update runs the script again, shows what it said if it fails, and restarts Mochi into the new version. Under systemd, the service restarts. |
| pacman, apt or dnf | The command for the package, like paru -Syu mochi-bin, with Copy and “Run in a terminal”. |
| Nix | nix flake update mochi and a rebuild, with Copy. How you rebuild is yours: set command, like ["nh", "os", "switch", "--update"], and “Run in a terminal” runs it. |
| A debug build from the source tree | git pull and cargo build in the tree. |
“Run in a terminal” opens terminal, or xdg-terminal-exec, or $TERMINAL, and the terminal waits for Enter once the command ends, so what it said stays readable.
The check asks GitHub’s API for the list of releases and sends nothing else. check = false turns it off; Check now still works. mochi ipc updater check looks right away.
| Action | What it does |
|---|---|
check | Looks for a new release now |
view, skip | Open the Updates page, or close the notice |
update | Updates with the install script and restarts, for a Mochi it installed |
run, copy | Run the update command in a terminal, or copy it |
open-release <version> | Opens a newer release’s page on GitHub |
# Updates: Mochi looks for a new release on GitHub, says so once on the
# island, and its page in the settings has the changelog and the update.
[module.updater]
# Look for a new release at start and then every few hours, as set below.
# Nothing is sent
# but the request for the list of releases.
# check = true
# Hours between two checks while Mochi runs.
# interval_hours = 12
# Your own update command, which "Run in a terminal" runs instead of the one
# for how Mochi was installed.
# command = []
# The terminal that runs it. None uses xdg-terminal-exec, or the one
# $TERMINAL names.
# terminal = []
Writing views
A module’s views are QML files in its qml/ directory. They import the core library with import qs.island, which has the theme, the built-in controls and the connection to the daemon.
Conventions
- Every view declares
property var payload. Island views get their activity’s payload; control center cards and pages get their module’s published state. - Island views size themselves with
implicitWidthandimplicitHeight, and the island follows. Control center cards and pages fill the space the control center gives them. - Colors, sizes and timings come from
Theme, never from literals:Theme.surfacefor a card,Theme.textBodyfor text,Theme.movefor movement. A change totheme.tomlthen restyles every module. - Actions go through
Daemon.command(module, action, args); arguments are strings. - Values that change many times a second, like the audio meters’ levels, come through
Daemon’slive(module, value)signal rather than the published state, fromModuleCtx::publish_live. Listen withConnections { target: Daemon }. Nothing keeps them: a view sees only those sent while it’s open.
Motion that only decorates
An animation that runs on its own, like bars bouncing to music or a wave drifting, draws a frame for every one of the monitor’s: 144 a second on a 144 Hz monitor, and two windows’ worth on two monitors, even hidden behind a fullscreen game. Drive it with a Ticker instead, which moves on 30 times a second, together with every other one, and run it only while the view can be seen:
import Quickshell
import qs.island
Ticker {
id: ticker
running: root.playing && root.visible && Daemon.shows(root.QsWindow.window) && !Theme.reducedMotion
}
// ticker.now, in milliseconds, holds still while it's stopped.
readonly property real swing: 0.5 - 0.5 * Math.cos(ticker.now % 900 / 900 * 2 * Math.PI)
Daemon.shows(window) is false while the window is hidden or a fullscreen window covers its monitor. A short animation that answers something the user did, like a panel opening, can stay an Animation. A view whose size changes on every update makes the island move each time, so keep rows that come and go at a fixed height. Profiling shows how many frames each window draws.
When a view doesn’t load
A view with a QML error, or a missing file, logs the error in mochid’s log as a quickshell warning, with the file and line, and the island keeps what it showed. When the view is a plugin’s override of a builtin view, the island and the bubbles load the builtin view instead and log could not load root:/modules/<module>/<view>.qml, trying root:/builtin/<module>/<view>.qml. The daemon keeps each overridden module’s own files in builtin/<module>/ in the shell tree for this.
Overlays
An activity can bring an overlay: ActivitySpec::overlay("Overlay") draws qml/Overlay.qml over every monitor, under the island and the bubbles, while the activity shows. It’s for picking something on screen, like the capture module’s region. The overlay gets the activity’s payload and a screen property with its monitor, and takes the clicks. Every monitor’s overlay asks for the keyboard, since Hyprland only sends the pointer to surfaces that hold it; the compositor gives it to one of them, so handle keys in each. If it declares property bool ready, the island waits for it to turn true before it changes, so an overlay can freeze the screen first.
Virtual screens
A module can make a monitor of its own through the compositor, named MOCHI-<MODULE>, like the share module’s MOCHI-SHARE. The shell gives it no island or bubbles; it shows the module’s qml/Screen.qml over the whole monitor instead, with the module’s published state as payload, and takes no clicks. Daemon.screens lists the real monitors only, and Daemon.virtualScreens the others; use Daemon.screens wherever you list monitors for the user.
Theme roles
| Role | For |
|---|---|
background | the island and the control center panel |
surface | cards and tiles |
raised | controls, tracks and dividers on those |
highlight | hovered controls |
foreground, muted | main and secondary text and icons |
accent, onAccent | what is active or important, and text on it |
danger, success | destructive actions, good news |
border, shadow | the hairline around the island and bubbles, and the shadow under them; the core draws both |
Theme scales
Views take every size from Theme’s scales, so modules and plugins look like one design:
| Scale | Tokens | For |
|---|---|---|
| Text | textCaption (11), textBody (13), textTitle (15), textHeadline (20), textDisplay (42) | labels and fine print; everything else; card, track and section titles; page titles; big numbers |
| Weight | weightBody, weightLabel, weightTitle | running text; labels; titles |
| Spacing | spaceTiny (4), spaceSmall (8), spaceMedium (12), spaceLarge (16), spaceHuge (24) | inside a group of small things; between an icon and its text or items in a row; between groups; around a card’s content; between sections |
| Corners | radiusSurface, radiusField, radiusControl, or height / 2 for round ends | cards, tiles and panels; rows, fields and buttons; chips, badges and icon buttons |
| Height | controlHeight (32), rowHeight (44), tileHeight (96) | a button, chip or field; a row in a list; a row of the control center’s grid |
Fonts are fontFamily and displayFamily, for clocks: Inter, which Mochi’s packages bring, unless theme.toml names another. Motion: fast for colors and hovers, move with the overshoot curve for things that move. The text sizes and corners follow theme.toml; the rest are fixed. textLabel and textSubtitle, from before the scale, still give textCaption and textBody for now.
A test in mochi-core (tests/design.rs) reads every view and rejects new raw sizes, spacing, corners, margins and colors. A line that needs one anyway says why in a // design: comment, like a badge’s 9 pixel count that has to fit in its dot.
Controls
| Control | What it is | Main properties |
|---|---|---|
Symbol | an icon: Mochi’s name or any Material Symbols name, else the icon theme | name, size, color, filled |
Button | a pill button; round with only an icon | text, icon, tone (neutral, accent, danger, ghost), clicked() |
IconButton | a round icon button sized from its icon | icon, size, tone, clicked() |
ActionButton | a Button the keyboard reaches with Tab and presses with Enter or Space, with a focus ring | text, icon, tone, clicked() |
Slider | a value from 0 to 1; thick with an icon, or thin as a seek bar | value, icon, thickness, reset (where a double click puts it), level (a sound’s level, drawn in the fill like a meter; off below 0), moved(value), released(value) |
ProgressBar | how far along, not interactive | value, fill |
Switch | on or off | checked, toggled(checked) |
Segmented | one choice out of a few; with keyboard, Tab reaches it and Left and Right pick | options ([{value, label, icon}]), current, keyboard, picked(value) |
Tile | a control-center tile, vertical for actions, horizontal for toggles | icon, title, subtitle, checked, tone, vertical, clicked() |
ListRow | a row with something at the start and controls at the end | icon or image or leading, title, subtitle (subtitleFormat: Text.StyledText for markup, with linkActivated(link)), trailing, selected, flat, marker, clicked() |
Badge | a count in an accent circle | count |
SectionLabel | the label above a group of controls | text |
PanelHeader | the top of a page or panel: a back button, an icon, the title, and items put inside on the right | title, back, icon, iconColor, backClicked() |
SwitchRow | a setting that is on or off, as a row whose click flips it | icon, title, subtitle, checked, toggled(checked) |
SliderRow | a level on a tile: an icon to click, a thin slider, the percentage and a chevron | icon, value, maximum (the percentage at 1), reset, level, opens, moved(value), released(value), iconClicked(), opened() |
RollingText | text whose digits roll when they change, for clocks, percentages and timers | text, pixelSize, weight, family, color, animated |
ScrollFade | fading edges on a list where more scrolls past them; put it inside the list | view, horizontal, color |
EdgeLight | a light along the top edge of a panel or tile: faint, toward the pointer on hover, sweeping while working, and flash() when something finishes | radius, working, color, flash() |
WavyProgress | how far along, as a line that waves and drifts forward while playing and lies flat when it stops, like a track’s progress, or stays flat with wavy off; seeks like a thin Slider, or only shows with interactive off | value, playing, wavy, interactive, thickness, fill, trackColor, moved(value), released(value) |
WavyRing | how full, as a ring filling clockwise from the top, wavy or flat, with what’s put inside in its middle | value, size, thickness, wavy, waves, color, trackColor |
ExpressiveShape | a filled shape behind one thing a widget sets apart, like today’s date or a clock, with what’s put inside on top. See the shapes below | shape, size, color, lobes (a cookie’s lobes or a burst’s points), angle (turns the shape, not what’s inside), roomWidth and roomHeight (read-only: the box in its middle where what’s inside fits) |
StackedTime | a big clock’s hour above its minutes in the display font, sized from the box, with a line under them; the digits roll | hours, minutes, date, color, dateColor, weight, horizontalAlignment, pixelSize (read-only) |
ClockTime | the time now in parts, here or in a time zone, for clocks; not drawn. A module reads zones’ offsets with mochi_core::zones and publishes them as zones and unknownZones, which payload takes | payload, zone, seconds, ticking, now, parts, known, unknown, city, half, hour(twelve), time(twelve, seconds), date(short) |
ZonePicker | picks time zones: a search field, then the zones that match, each as “Tokyo, Asia” with “UTC+9 · Japan” under it, the chosen ones checked; before a search, the chosen ones, then suggested, then every zone west to east. Up, Down and Enter move and pick, Escape says closed. zones is what a module publishes from mochi_core::zones::system with Zone::choice; publish it only while the picker shows, since there are a few hundred. Without searchField, the owner’s field sets query and passes keys on with move(step) and accept(). The search itself is Zones.js | zones, chosen, suggested, titles, most, custom, searchField, query, limit, color, fieldColor, picked(value), closed(), focusSearch(), type(text), clear() |
Credit | a credit for the bottom of a module’s settings page: “This module is inspired by the work of” its author, and an underlined See repo that opens link through the settings module’s open-link. Offer it as a section to settings with options.place = "bottom" | author, link |
Controls report what the user did and leave the state to the owner: a Switch sends toggled, and the view sets checked once the module confirms. mochi ipc demo controls shows them all.
WavyProgress, WavyRing and ExpressiveShape are accents. A widget uses one of them, on the thing it sets apart, like the playing track’s progress or today’s date, and draws the rest plainly. The theme’s waves = false in [motion] keeps both wavy pieces flat, whatever their wavy says, so a plugin needs no setting of its own for it.
ExpressiveShape fills the largest square in its box, except the pill, which takes the box’s width and up to 0.62 of it in height. Its shapes:
shape | What it is | Room inside |
|---|---|---|
circle | a circle | 0.7 of the side |
pentagon | a pentagon with round corners, a point up | 0.6 by 0.52 |
cookie | soft lobes all around, 9 by default (lobes) | 0.66 |
clover | four round lobes | 0.56 |
burst | soft points all around, 12 by default (lobes) | 0.6 |
hexagon | a hexagon with round corners, a flat side up | 0.72 by 0.6 |
octagon | an octagon with round corners, a flat side up | 0.74 |
squircle | a square with soft sides, between a square and a circle | 0.8 |
pill | a wide pill with round ends | the width less 0.4 of the height, by 0.72 of the height |
A view sizes what goes inside from roomWidth and roomHeight rather than from the side, so the same text fits whichever shape a setting picks. The clock widget and the clock panel’s Today tab let users pick the shape, or none. mochi ipc demo controls shows every shape.
Icons come from Material Symbols Rounded, which Mochi’s packages bring. Symbol takes Mochi’s names: home, bell, music, clock, grid, moon, search, play, pause, next, previous, note, volume, volume-0 to volume-3, volume-muted, mic, mic-muted, headset, speakers, display, caps-lock, num-lock, keyboard, wifi, wifi-1, wifi-2, wifi-off, ethernet, offline, airplane, bluetooth, power, lock, logout, reboot, snow, chip, memory, gpu, disk, temperature, leaf, bolt, scale, camera, video, record, stop, region, window, copy, clipboard, palette, edit, pin, trash, folder, close, check, chevron, plus, minus, tray, dot. It also takes any Material Symbols name, like timer or wb_sunny. Without the font, Mochi’s names are drawn instead. Any other name, like an app’s, is looked up in the icon theme. filled fills the outlined ones, for an active state.
Writing plugins
A plugin is a directory, usually a git repository, with a manifest, views and a backend:
my-plugin/
mochi-plugin.toml what it is, what it runs, what it offers
settings.toml its commented [module.<id>] section, for users
qml/ its views
src/, Cargo.toml the backend's source, for a Rust backend
The repository has example plugins to copy:
| Example | Shows |
|---|---|
examples/plugins/pomodoro | A Rust backend: a countdown bubble updated every second, island notices, actions with arguments, a control center card with buttons, watching the media module’s state |
examples/plugins/meteo | A Rust backend fetching from the web on a timer, settings with a place and units, a control center card and a forecast view. Mochi has a weather module of its own; this is the same idea as a plugin |
examples/plugins/emoji | A Rust backend that is a launcher provider: an emoji picker with no views |
examples/python/hello | A Python backend with a small SDK of its own: see Making an SDK |
To work on a plugin, list it with a path: source and install it, which runs its build:
# ~/.config/mochi/plugins.toml
[plugins.pomodoro]
source = "path:~/code/mochi-pomodoro"
mochi plugins install pomodoro # builds it; mochid reloads
Views hot-reload as you save them. After rebuilding the backend, mochi reload restarts it: mochid restarts a plugin whose manifest or backend changed.
The manifest
mochi-plugin.toml at the plugin’s root names the plugin, its backend, its actions and what it offers. The smallest one, for a plugin of views only:
[plugin]
id = "clock"
name = "Big clock"
version = "0.1.0"
api = 1
[views]
overrides = ["idle/Pill"]
A plugin with a backend adds [backend] with the program and the command that builds it, and usually [[actions]] and [[contributions]]. Plugin manifest lists every key.
Views
Views are QML files in the views directory, loaded the same way as a builtin module’s: see Writing views. An activity or bubble names a view by its file name without .qml, and a view gets the payload property. import qs.island gives the theme, Daemon and the controls. A view reads its plugin’s state with Daemon.state("<id>") and runs its actions with Daemon.command("<id>", "<action>", [args]).
A control center card or page gets the plugin’s published state as its payload, and a card can set hidden: true to step aside. The control center draws the card’s frame and title, so the view only draws what goes inside, filling the width it’s given.
Replacing builtin views
overrides = ["idle/Pill"] puts the plugin’s qml/overrides/idle/Pill.qml in place of the idle module’s Pill.qml, while both modules are enabled. The file sits in the idle module’s directory, so it can use that module’s other files and gets the same payload as the view it replaces. Without the plugin, the builtin view is back. An override that fails to load, with a QML error for example, gives way to the builtin view, and mochid’s log has the error. When two plugins replace the same view, the one whose id sorts first wins.
The backend in Rust
Depend on mochi-sdk, and hand your function to mochi_sdk::run. It gets a ModuleCtx with the same calls as a builtin module’s:
use mochi_sdk::{ActivitySpec, ModuleCtx, ModuleEvent, json};
fn main() -> std::process::ExitCode {
mochi_sdk::run(run)
}
async fn run(mut ctx: ModuleCtx) -> Result<(), mochi_sdk::Error> {
while let Some(event) = ctx.next_event().await {
match event {
ModuleEvent::Command(command) if command.action == "say" => {
ctx.present(
ActivitySpec::new("Hello")
.timeout(std::time::Duration::from_secs(3))
.payload(json!({ "text": "Hi" })),
);
command.reply(Ok(()));
}
ModuleEvent::Command(command) => command.reply(Err("no such action".into())),
_ => {}
}
}
// mochid closed the connection: time to go.
Ok(())
}
The Rust SDK covers settings, activities, bubbles, state, calls, the compositor, logging and testing.
A backend in any language
A backend is any program that speaks the plugin protocol: JSON lines over file descriptor 3. This one, in sh, answers an action with an activity. For more than a few lines, a small library helps: Making an SDK explains how to write one, with a complete one in Python.
#!/bin/sh
read -r hello <&3
printf '{"type":"hello","api":1}\n' >&3
while read -r line <&3; do
case "$line" in
*'"type":"command"'*)
id=${line#*\"id\":}
id=${id%%,*}
printf '{"type":"present","id":1,"spec":{"compact":"Hello","timeout_ms":3000}}\n' >&3
printf '{"type":"reply","id":%s}\n' "$id" >&3 ;;
esac
done
A flake for Nix users
You don’t need one: Mochi builds Rust, Node, Python and Go plugins with Nix from their lock files by itself, see Building with Nix. List the programs your backend runs in [backend] needs, so they’re there wherever it’s built.
A flake is for a build Mochi’s builder can’t guess, like extra native libraries. mochi plugins install uses it when Nix is installed, and home-manager can take its package. Copy this next to mochi-plugin.toml and adjust it; mochi.lib.buildPlugin is the same builder:
# A flake for a plugin's repository, for a build Mochi can't guess by
# itself, like extra native libraries: copy it next to mochi-plugin.toml.
# Without one, Mochi builds Rust, Node, Python and Go plugins with Nix from
# their lock files anyway. With it:
#
# - `mochi plugins install` builds it with `nix build` when Nix is
# installed, instead of the manifest's `build` command.
# - home-manager can take the package as
# `programs.mochi.plugins.<id>.package = inputs.<plugin>.packages.${pkgs.system}.default;`
#
# `mochi.lib.buildPlugin` follows the plugin's lock file, so there's no
# hash to update, and puts the backend at the manifest's `exec`.
{
description = "A Mochi plugin";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
mochi = {
url = "github:Davidutz19/mochi";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ nixpkgs, mochi, ... }:
let
systems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
in
{
packages = forAllSystems (pkgs: {
default = mochi.lib.buildPlugin pkgs {
src = ./.;
# Native libraries the backend links, if any.
# buildInputs = [ pkgs.alsa-lib ];
};
});
};
}
A flake for a plugin in another language works too, as long as its default package has the backend at the manifest’s exec, or in bin/ by the same name.
The mochi-sdk dependency must be a git one, like mochi-sdk = { git = "https://github.com/Davidutz19/mochi", tag = "v0.4.7" }, not a path to your own checkout, or the plugin only builds on your machine.
Publishing a release
Releases work for the most people: nothing to build, so no compiler, no libraries and no Nix needed, and Mochi patches release binaries to run on NixOS too. Building from source depends on each machine having your plugin’s build environment, and Mochi’s Nix build covers the usual builds of Rust, Node, Python and Go, not every plugin. Publish releases if your plugin compiles to a binary, and always if it’s in a language Mochi can’t build with Nix, see Which source to pick.
For a git-release: source, attach an archive to a release on GitHub, on a Forgejo or Gitea like Codeberg, or on a GitLab, named as [release] asset says with {id}, {version}, {tag} and {arch} (x86_64 or aarch64) filled in. On GitLab, a release’s assets are links: give the link that name, and point it at the archive, in the project’s package registry for instance. The archive holds the plugin as it should be installed: the manifest, the views and the built exec, at its root or in one directory. mochi plugins install reads the manifest from the tagged commit first, to show what it will install, then downloads the asset.
The same archive works without a forge too: put it anywhere over HTTPS, and users list it with its hash, as source = "https://example.org/clock-1.0-x86_64.tar.gz#sha256=<hash>", the hash being what sha256sum prints for the file. An archive pins one architecture and one version, so mochi plugins update never moves it; git-release: picks the asset for each machine and finds new releases.
This GitHub Actions workflow does it on every tag: copy it to .github/workflows/release.yml in the plugin’s repository. It reads the manifest, builds the backend on x86_64 and aarch64, packs the manifest, settings.toml, the views and the built exec, and attaches the archive to the tag’s release. A Rust backend is built as a static binary for the musl target rather than with build, so it runs on any Linux, NixOS included, with no loader or libraries to find; the binary is the one named like exec’s file. For another language it runs build; make the binary static if the language can, like Go with CGO_ENABLED=0. On another forge, its CI or a release made by hand attaches the same archive.
# A GitHub Actions workflow for a plugin repository, for `git-release:`
# sources. Copy it to .github/workflows/release.yml. Pushing a tag like
# v0.1.0 builds the backend on x86_64 and aarch64, packs what
# `mochi plugins install` needs, and attaches it to the tag's release under
# the name `[release] asset` gives.
#
# A Rust backend, one with a Cargo.toml, is built as a static binary for
# the musl target instead of with the manifest's `build`: it needs no
# loader and no libraries, so it runs on any Linux, NixOS without nix-ld
# included. The binary is the one named like `exec`'s file, `meteo` for
# `bin/meteo`. Each architecture builds on its own runner, so the Rust
# toolchain links it with the runner's `cc` and the musl that comes with the
# target; musl-tools gives `musl-gcc` for crates that compile C.
#
# It reads everything from mochi-plugin.toml, so it needs no changes for a
# Rust backend. For another language, `build` runs as it is: add the steps
# that install its tools before "Build", and build it static if the
# language can, like Go with CGO_ENABLED=0.
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
jobs:
release:
strategy:
matrix:
include:
- arch: x86_64
runner: ubuntu-24.04
- arch: aarch64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
env:
TARGET: ${{ matrix.arch }}-unknown-linux-musl
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ env.TARGET }}
- name: Install musl
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Read the manifest
id: manifest
env:
TAG: ${{ github.ref_name }}
ARCH: ${{ matrix.arch }}
run: |
python3 - >> "$GITHUB_OUTPUT" <<'PY'
import os, tomllib
manifest = tomllib.load(open("mochi-plugin.toml", "rb"))
plugin = manifest["plugin"]
asset = manifest["release"]["asset"]
for key, value in {
"{id}": plugin["id"],
"{version}": plugin["version"],
"{tag}": os.environ["TAG"],
"{arch}": os.environ["ARCH"],
}.items():
asset = asset.replace(key, value)
backend = manifest.get("backend", {})
print(f"id={plugin['id']}")
print(f"asset={asset}")
print(f"exec={backend.get('exec', '')}")
print(f"views={manifest.get('views', {}).get('dir', 'qml')}")
print(f"build={backend.get('build', '')}")
PY
- name: Build
if: steps.manifest.outputs.build != ''
env:
MOCHI_PLUGIN_DIR: ${{ github.workspace }}
BUILD: ${{ steps.manifest.outputs.build }}
EXEC: ${{ steps.manifest.outputs.exec }}
run: |
if [ ! -f Cargo.toml ]; then
sh -c "$BUILD"
exit
fi
# C code in the dependencies compiles against musl too.
export "CC_$(echo "$TARGET" | tr - _)=musl-gcc"
name=$(basename "$EXEC")
cargo build --release --locked --target "$TARGET" --target-dir target --bin "$name"
install -Dm755 "target/$TARGET/release/$name" "$EXEC"
# A dynamically linked binary fails the release.
linked=$(file "$EXEC")
echo "$linked"
case "$linked" in
*static*) ;;
*) echo "$EXEC isn't static" >&2; exit 1 ;;
esac
- name: Pack
env:
ID: ${{ steps.manifest.outputs.id }}
ASSET: ${{ steps.manifest.outputs.asset }}
EXEC: ${{ steps.manifest.outputs.exec }}
VIEWS: ${{ steps.manifest.outputs.views }}
run: |
# The plugin as it should be installed, in one directory.
mkdir -p "pack/$ID"
for path in mochi-plugin.toml settings.toml README.md LICENSE "$VIEWS" "$EXEC"; do
if [ -n "$path" ] && [ -e "$path" ]; then
cp -r --parents "$path" "pack/$ID/"
fi
done
tar -czf "$ASSET" -C pack "$ID"
tar -tzf "$ASSET"
- name: Attach to the release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
ASSET: ${{ steps.manifest.outputs.asset }}
run: |
# Both jobs race to make the release; the second just uploads.
gh release create "$TAG" --title "$TAG" --notes "" --verify-tag 2>/dev/null || true
gh release upload "$TAG" "$ASSET" --clobber
Plugin manifest
mochi-plugin.toml sits at the root of a plugin and says what it is, what it runs and what it offers. mochid reads it when it starts and on mochi reload; mochi plugins install reads it before installing, to show you. A key the manifest doesn’t know is an error, so typos don’t go unnoticed.
A complete one, from the pomodoro example:
# An example plugin: a focus timer. `mochi ipc pomodoro start` starts 25
# minutes of focus; a bubble counts down, and the island says when it's
# time for a break.
[plugin]
id = "pomodoro"
name = "Pomodoro"
version = "0.1.0"
description = "A focus timer: a bubble counts down, the island says when to rest"
authors = ["Mochi"]
api = 1
[backend]
exec = "bin/pomodoro"
# Its own target directory, so it builds the same inside the Mochi
# repository and in a repository of its own.
build = "cargo build --release --locked --target-dir target && install -Dm755 target/release/pomodoro bin/pomodoro"
[release]
asset = "pomodoro-{version}-{arch}-linux.tar.gz"
[bubbles]
area = "center-right"
[uses]
# With `pause_media`, a focus session pauses what's playing.
state = ["media"]
[[actions]]
name = "start"
description = "Start a focus session"
args = [{ name = "minutes", description = "How long, instead of focus_minutes", kind = "int", optional = true }]
[[actions]]
name = "break"
description = "Start a break"
args = [{ name = "minutes", description = "How long, instead of break_minutes", kind = "int", optional = true }]
[[actions]]
name = "pause"
description = "Pause or resume the timer"
[[actions]]
name = "stop"
description = "Stop the timer"
[[actions]]
name = "status"
description = "Print what the timer is doing"
[[contributions]]
target = "control-center"
kind = "card"
id = "timer"
view = "Card"
title = "Focus"
icon = "clock"
order = 60
options = { span = 1, rows = 1 }
[plugin]
| Key | ||
|---|---|---|
id | required | Its name in config.toml, [module.<id>], mochi ipc <id> and Daemon.state("<id>"). Lowercase letters, digits, - and _, starting with a letter. It must match the id in plugins.toml, and can’t be a builtin module’s. |
name | required | What mochi plugins shows. |
version | required | The plugin’s own version, any text. plugins.lock records it, and {version} in a release asset’s name is it. |
api | required | The protocol version the backend speaks: 1. mochid refuses a plugin with another. |
description | One line about it. | |
authors | A list of names. | |
homepage | A URL. |
[backend]
Leave it out for a plugin of views only, like one that only replaces a builtin view.
| Key | ||
|---|---|---|
exec | required | The program mochid starts, relative to the plugin’s directory. |
args | Its arguments. | |
build | A shell command that builds exec from source. mochi plugins install runs it with sh in the plugin’s directory for git: and path: sources, with MOCHI_PLUGIN_DIR set; never for git-release:, nor when Nix builds the plugin instead, see Building with Nix. | |
needs | Programs the backend runs, by command name, like ["python3", "ffmpeg"]. When Nix builds the plugin, they go on the backend’s PATH; otherwise install lists the missing ones and mochid warns about them when the plugin starts. | |
kind | How Nix builds the backend, when the plugin’s files don’t tell: rust, node, python, go or files. See below. |
The backend starts in the plugin’s directory, with the socket to mochid as file descriptor 3. See the plugin protocol.
Building with Nix
Mochi can build a plugin with Nix, so people on NixOS, or without the plugin’s build tools, can use it: home-manager’s programs.mochi.plugins.<id>.src, and mochi plugins install when Nix is installed but the build’s tools or the needs aren’t. You write no Nix and no hashes: the build follows the lock file the plugin already has, found from its files, or from kind:
kind | Found from | What Nix does |
|---|---|---|
rust | Cargo.lock | Builds it with cargo, git dependencies included. |
node | package-lock.json | Installs the dependencies, and runs npm run build when package.json has one. |
go | go.mod | Builds it with the dependencies in vendor/. Without vendor/ Nix would need a hash, so commit it (go mod vendor) or publish releases. |
python | pyproject.toml or requirements.txt | Runs the backend with a Python that has its dependencies, from nixpkgs’ Python packages. |
files | exec already there | Uses the plugin as it is: a script, or a release archive with a built binary, which gets patched to find NixOS’s libraries. |
In every case the backend ends up at exec, with the needs on its PATH and #!/usr/bin/env lines pointing at them. For compiled languages without a lock file Nix can read, like Java, publish releases: a release archive works as src too.
[release]
For git-release: sources.
| Key | ||
|---|---|---|
asset | required | The release asset’s file name. {id}, {version}, {tag} and {arch} are filled in; {arch} is x86_64 or aarch64. |
The asset is a tar archive, compressed or not, holding the plugin as it should be installed, built exec included: at the archive’s root, or in its only directory.
[views]
| Key | Default | |
|---|---|---|
dir | "qml" | Where the views are, relative to the plugin’s directory. |
overrides | [] | Builtin views it replaces, as "<module>/<view>". The plugin’s <dir>/overrides/<module>/<view>.qml takes the place of the module’s <view>.qml while both are enabled. |
[uses]
| Key | Default | |
|---|---|---|
state | [] | Modules whose published state the backend receives, as state messages: once at the start, then on every change, and null when the module stops. A module that isn’t enabled sends nothing. |
[bubbles]
Where the plugin’s bubbles go unless the user moves them. Settings › Bubbles shows the plugin there before its first bubble appears; without this table, the plugin shows up there only once it has shown one. Say the same area, group and order the backend’s show_bubble gives.
| Key | Default | |
|---|---|---|
area | required | left, center-left, center, center-right or right. |
group | none | Shares a pill with the bubbles of the same group, like the builtin status. |
order | 0 | Lower goes further left. |
wide | false | It has a wide view with text, so the editor offers the “With text” switch. |
[bubbles]
area = "right"
[[actions]]
One table per action mochi ipc <id> <action> runs. mochid checks the words typed against the arguments before the backend sees them, and mochi ipc <id> lists the actions with their help.
| Key | ||
|---|---|---|
name | required | One word. |
description | required | One line, for mochi ipc’s list. |
args | A list of arguments, in order. |
An argument:
| Key | Default | |
|---|---|---|
name | required | The name the backend reads it by. |
description | "" | One line. |
kind | "string" | string, int, float, bool (true/false, on/off, yes/no) or choice. |
choices | [] | The words a choice takes. |
optional | false | May be left out; only trailing arguments can be optional. |
rest | false | Takes every remaining word, joined with spaces; only the last argument. |
source | none | Where its values come from, so the settings panel offers them in a menu when an option runs this action: output, app, desktop-id, player, control-center-page, audio-output and the others the builtin modules use. |
The backend gets the arguments as an object: {"minutes": 25, "label": "Write"}. A left-out optional argument isn’t there.
[[contributions]]
What the plugin offers other modules, like a card or a page for the control center. The view gets the plugin’s published state as its payload.
| Key | ||
|---|---|---|
target | required | The module it’s for, like control-center, or mochi for the shell itself. |
kind | required | What it is to the target: the control center takes card and page, the launcher provider, and the settings section, a view drawn on the module’s own page above its options. The shell, mochi, takes preload: a view it compiles while idle after starting, so the first time it shows doesn’t wait for that. A panel the plugin opens on the island is worth it; { offered = ["card"] } compiles the views other modules offer the plugin as those kinds with it. |
id | required | Unique among the plugin’s contributions. |
view | The view’s file name, without .qml. Kinds without a view, like a launcher provider, leave it out. | |
title | required | Its heading. |
icon | A Mochi symbol, like clock, or an icon theme name. | |
order | 0 | Lower comes first. |
options | Anything else the target reads, like { span = 2, rows = 1 } for a control center card two columns wide and one row tall. A card with rows gets a view sized to fill them, about 45 pixels tall for one row and 153 for two; without it, the control center measures the view. A control center card opens its plugin’s page when clicked; { page = "<id>" } picks which, when there are several. A launcher provider takes prefix, search and pick: see Launcher providers. |
[settings]
How the settings panel shows the options in settings.toml. Each option’s kind and default come from its # key = value line there, and its description from the comment above the line. A [settings.<key>] table adds what the line can’t say. An option in a table is named with dots: [settings."cpu.notice"].
| Key | ||
|---|---|---|
choices | The values it takes: the panel shows them to pick from. | |
min, max | A number’s range. With both, the panel shows a slider. | |
color | false | A #rrggbb or #aarrggbb color, with a picker. |
font | false | A font family, picked from the fonts installed. |
optional | false | It may be left unset. |
description | In place of the comment in settings.toml. |
[settings.units]
choices = ["metric", "imperial"]
[settings.refresh_minutes]
min = 5
max = 120
An option without a table shows as its default’s kind: a switch, a number, a text field or a list. A table by default, like a map of names, is edited as TOML.
settings.toml
Not part of the manifest, but next to it by convention: the plugin’s [module.<id>] section with every setting commented out at its default, for users to copy into config.toml. The backend gets the section in hello, and the settings panel shows each setting from it.
The Rust SDK
mochi-sdk writes plugin backends in Rust. It speaks the plugin protocol for you, and its ModuleCtx has the same calls as a builtin module’s, so code moves between a plugin and a builtin with few changes. The API documentation lists every type and method; this page shows how they fit together.
Setting up
A plugin’s backend is a binary crate:
[package]
name = "mochi-plugin-pomodoro"
version = "0.1.0"
edition = "2024"
[[bin]]
name = "pomodoro"
path = "src/main.rs"
[dependencies]
mochi-sdk = { git = "https://github.com/Davidutz19/mochi", tag = "v0.4.7" }
serde = { version = "1", features = ["derive"] }
tokio = { version = "1", features = ["macros", "time"] }
Pin the tag of the Mochi release you build against. The SDK speaks protocol API 1, which every Mochi 0.0.x speaks: a plugin built with an older SDK keeps working with a newer Mochi until the API changes.
The manifest’s build compiles it and puts the binary where exec says:
[backend]
exec = "bin/pomodoro"
build = "cargo build --release --locked --target-dir target && install -Dm755 target/release/pomodoro bin/pomodoro"
Running
mochi_sdk::run connects to mochid, says hello, runs your function on a single-threaded tokio runtime, and turns its result into the exit code:
fn main() -> std::process::ExitCode {
mochi_sdk::run(run)
}
async fn run(mut ctx: mochi_sdk::ModuleCtx) -> Result<(), mochi_sdk::Error> {
while let Some(event) = ctx.next_event().await {
// ...
}
Ok(())
}
next_event returns None when mochid closes the connection: when it stops, reloads with the plugin disabled or changed, or shuts down. Return then; a backend still running 1.5 seconds later is killed. An Err from your function, or a panic, counts as a crash, and mochid starts the backend again.
For another runtime, like a multi-threaded one, call ModuleCtx::connect().await from your own main. It fails when the program wasn’t started by mochid, so running the binary by hand says so instead of hanging.
Settings
The plugin’s [module.<id>] table from config.toml arrives with the connection. Read it into a type of your own:
#![allow(unused)]
fn main() {
#[derive(serde::Deserialize)]
#[serde(default, deny_unknown_fields)]
struct Settings {
focus_minutes: u64,
area: mochi_sdk::Area,
}
impl Default for Settings {
fn default() -> Self {
Self { focus_minutes: 25, area: mochi_sdk::Area::CenterRight }
}
}
let settings: Settings = ctx.settings()?;
}
With deny_unknown_fields, a typo in config.toml makes the backend exit with an error naming the key, which mochid logs. It fails the same way after each restart, so it soon stays stopped: mochi status says it failed, and the log has why. Fix the file and run mochi reload. Settings only change with a reload, which restarts the plugin, so read them once.
Events
ModuleEvent | Comes when |
|---|---|
Command(command) | mochi ipc <id> <action>, a button in a view running Daemon.command, or another module’s call |
Clicked(activity) | A click on one of its activities that has no expanded view |
Hovered { activity, hovered } | The pointer came onto one of its activities on the island, or left it |
Ended { activity, reason } | One of its activities is gone: Expired, Dismissed, Withdrawn, Replaced or Outside |
BubbleClicked(bubble) | A click on one of its bubbles |
State { module, state } | A module from [uses] state published state |
Offers(contributions) | What other modules offer this one, like launcher providers to a launcher: at the start, then after each reload that changes it |
To do work on a timer as well, wait on both with tokio::select!:
#![allow(unused)]
fn main() {
let mut tick = tokio::time::interval(std::time::Duration::from_secs(1));
loop {
tokio::select! {
event = ctx.next_event() => match event {
None => return Ok(()),
Some(event) => handle(&ctx, event),
},
_ = tick.tick() => refresh(&ctx),
}
}
}
Commands
A command has the action’s name and its args, already checked against the manifest. Read arguments by name with the getter for their kind: args.str("label"), args.int("minutes"), args.float(..), args.bool(..). An optional argument that was left out is None.
Answer every command, once:
#![allow(unused)]
fn main() {
command.reply(Ok(())); // done
command.reply(Err("no timer runs".into())); // mochi ipc prints it and fails
command.answer(Ok(format!("{left} left"))); // mochi ipc prints the output
}
A command can wait for its answer, held in a variable or moved into a task, while the plugin goes on with other events: the caller waits with it. Dropping a command without answering fails it for the caller.
Activities
present submits an activity to the island and returns its id at once; the arbiter decides when it shows, by priority. ActivitySpec::new("Done") shows the view Done.qml, with these on top:
| Builder | Does |
|---|---|
.payload(json!({..})) | What the views get as payload |
.timeout(duration) | Ends it after this long on screen; the time stops while hovered or expanded |
.priority(Priority::HIGH) | LOW, NORMAL (the default), HIGH, URGENT, or Priority(n) for anything between |
.key("timer") | Replaces the plugin’s activity with the same key instead of adding one; with the same view, it updates in place |
.expanded("Big") | The view a click opens; without one, clicks come as Clicked |
.expand_for(duration) | Opens on the expanded view, then collapses after this long |
.uninterruptible() | Higher priorities wait instead of interrupting it |
.same_priority(SamePriority::Stack) | Interrupts a shown activity of the same priority instead of waiting |
.modal() | Takes the keyboard, for views you type into |
.overlay("Pick") | A full-screen view on every monitor under the island, for picking something on screen |
.passive() | A click outside doesn’t close it |
.fleeting() | Shows at once or not at all, never waiting in the queue |
.over_fullscreen() | Shows over a fullscreen window, like a game, which hides the island otherwise; for feedback on something the user just did |
.output("DP-3") | On this monitor’s island only, whatever [island] panels and notices say; it waits only behind what that island shows |
update(id, payload) changes what it shows, and withdraw(id) removes it. Each activity ends exactly once, with an Ended event.
Bubbles
show_bubble puts a small view next to the island and returns its id. BubbleSpec::new("Bubble") shows Bubble.qml, a view about 26 pixels tall:
| Builder | Does |
|---|---|
.payload(json!({..})) | What the view gets |
.area(Area::Right) | Left, CenterLeft, CenterRight (the default) or Right; the user’s [bubbles.<id>] settings win |
.key("timer") | Replaces the plugin’s bubble with the same key, keeping its place |
.wide("BubbleWide") | A wider view with text, for users who set wide = true |
.group("status") | Bubbles with the same group next to each other share a pill |
.order(n) | Lower goes further left |
.priority(..) | Breaks ties, decides who stays when an area is full and who is in front of a stack |
.news() | With stacked bubbles, brings it to the front for a while |
update_bubble(id, payload) changes it in place, and hide_bubble(id) removes it.
State
publish_state(json!({..})) replaces the plugin’s state. Views read it with Daemon.state("<id>"), control center cards and pages get it as their payload, and other modules can watch it. Publish the whole state each time, not a change.
To read another module’s state, name it in the manifest’s [uses] state, then match ModuleEvent::State:
#![allow(unused)]
fn main() {
Some(ModuleEvent::State { module, state }) if module == "media" => {
playing = state["status"] == "playing";
}
}
It comes once at the start when the module has published something, then on every change, and as Value::Null when that module stops.
Calling other modules
call runs another module’s action, with the same checks as mochi ipc, and returns a future that doesn’t borrow the context:
#![allow(unused)]
fn main() {
let call = ctx.call("media", "pause", &[]);
tokio::spawn(async move {
match call.await {
Ok(()) | Err(CallError::NotEnabled(_)) => {}
Err(error) => eprintln!("pausing failed: {error}"),
}
});
}
ask does the same and returns what the action answered with, like the output mochi ipc prints: Ok(Some(text)), or Ok(None) for an action that answered nothing. The launcher asks providers this way.
CallError::NotEnabled means the module isn’t enabled: the usual case for using another module when it’s there and carrying on when it isn’t. Spawn the call rather than awaiting it in your event loop when the other module might call back: each would wait for the other.
The compositor
ctx.compositor() is the latest state: outputs, workspaces, focused_output, focused_app, screencast with what’s captured, and keyboard_layout, the active layout’s name, on Hyprland, niri and Sway. compositor_changes() is a tokio::sync::watch::Receiver that wakes on every new state. Check backend: without a supported compositor it’s "unsupported" and the lists stay empty.
activate_workspace(id), windows() and pointer_output() ask the compositor and return futures, like call.
Files
data_dir() is a directory only this plugin writes to, emptied when mochid starts: for files its views load, like an image it downloaded. session_dir() keeps its files across mochid restarts, until you log out. Both are in the runtime directory. For anything that should last longer, use $XDG_DATA_HOME or $XDG_CACHE_HOME yourself.
The backend starts in the plugin’s directory, which MOCHI_PLUGIN_DIR also names.
Logging
What the backend prints goes to mochid’s log, tagged with the plugin’s id: stdout at the info level, stderr as warnings. journalctl --user -u mochid shows them under systemd. println! is fine: the protocol has a socket of its own.
Testing
Logic that doesn’t need mochid tests like any Rust code. To test the plugin’s conversation, play mochid: ModuleCtx::over takes one end of a socket pair, and the test sends mochid’s hello and reads what the plugin sends, with the message types from mochi_sdk::protocol:
#![allow(unused)]
fn main() {
use mochi_sdk::protocol::plugin::{CompositorState, FromPlugin, ToPlugin};
use mochi_sdk::protocol::{decode, encode};
use mochi_sdk::{ActivitySpec, ModuleCtx, ModuleEvent, json};
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
use tokio::net::UnixStream;
/// The plugin under test: `say` shows its text on the island.
async fn plugin(mut ctx: ModuleCtx) -> Result<(), mochi_sdk::Error> {
while let Some(event) = ctx.next_event().await {
if let ModuleEvent::Command(command) = event {
let text = command.args.str("text").unwrap_or("hi").to_owned();
ctx.present(ActivitySpec::new("Say").payload(json!({ "text": text })));
command.reply(Ok(()));
}
}
Ok(())
}
#[tokio::test]
async fn say_shows_the_text() {
let (mochid, theirs) = UnixStream::pair().unwrap();
let (reader, mut writer) = mochid.into_split();
let mut lines = BufReader::new(reader).lines();
// mochid speaks first.
let hello = ToPlugin::Hello {
api: mochi_sdk::API,
version: "test".into(),
module: "say".into(),
settings: json!({}),
data_dir: "/tmp/say".into(),
session_dir: "/tmp/say".into(),
compositor: CompositorState::default(),
};
writer.write_all(&encode(&hello).unwrap()).await.unwrap();
let ctx = ModuleCtx::over(theirs).await.unwrap();
let running = tokio::spawn(plugin(ctx));
let mut next =
async || -> FromPlugin { decode(&lines.next_line().await.unwrap().unwrap()).unwrap() };
assert_eq!(
next().await,
FromPlugin::Hello {
api: mochi_sdk::API
}
);
// `mochi ipc say say there`, as mochid hands it over.
let command = ToPlugin::Command {
id: 1,
action: "say".into(),
args: serde_json::from_value(json!({ "text": "there" })).unwrap(),
};
writer.write_all(&encode(&command).unwrap()).await.unwrap();
let FromPlugin::Present { spec, .. } = next().await else {
panic!("expected an activity");
};
assert_eq!(spec.payload, json!({ "text": "there" }));
assert_eq!(
next().await,
FromPlugin::Reply {
id: 1,
output: None,
error: None
}
);
// Closing the connection ends the plugin.
drop(writer);
running.await.unwrap().unwrap();
}
}
To try it for real, list the plugin with a path: source and run mochi plugins install <id>, which builds it; mochi reload restarts it after each rebuild.
Between a plugin and a builtin
ModuleCtx, ModuleEvent, ModuleCommand, ActivitySpec, BubbleSpec, Priority, Area, Args and CallError have the same names and calls in mochi-sdk and in mochi-core, so a plugin can become a builtin module, or the reverse, with few changes. The differences:
Builtin (mochi-core) | Plugin (mochi-sdk) | |
|---|---|---|
| Entry point | impl Module, with run(self, ctx) | mochi_sdk::run(function) |
| Actions, contributions, views | Declared in Rust | Declared in the manifest |
settings::<T>() errors | toml::de::Error | serde_json::Error |
| Watching state | ctx.watch_state("media") | [uses] state in the manifest |
| Compositor | ctx.compositor() returns a handle with state() and subscribe() | compositor() returns the state; compositor_changes() subscribes |
| Virtual monitors | create_virtual_output and the like | Not yet |
Making an SDK
A plugin backend can be written in any language: mochid starts a program and talks JSON lines with it over a socket. A backend can speak the plugin protocol directly, as the sh one on the Writing plugins page does, but a small library makes plugins in a language pleasant to write. This page is a guide to writing that library: what it must do, what it should do, and a complete one in Python to start from.
The Python SDK below is examples/python/hello/mochi_plugin.py in the repository, with an example plugin next to it. Mochi’s test suite runs that plugin in a real mochid, so the code on this page works.
What an SDK does
1. Connect
mochid starts the backend with these:
| File descriptor 3 | One end of a Unix stream socket to mochid. MOCHI_PLUGIN_FD holds the number, 3; read it rather than assume it. |
MOCHI_PLUGIN_DIR | The plugin’s directory, which is also the working directory. |
| stdout, stderr | Read by mochid line by line into its log, tagged with the plugin’s id. |
| stdin | Empty. |
Wrap the descriptor in the language’s socket type: socket.socket(fileno=3) in Python, net.FileConn(os.NewFile(3, "")) in Go, new net.Socket({ fd: 3 }) in Node. When MOCHI_PLUGIN_FD isn’t set, the program was run by hand: exit with a message saying mochid starts it, rather than wait forever.
2. Read and write lines
Every message is one JSON object on one line, ended by \n, at most 1 MiB. Keep a buffer and split it at newlines: a read can return half a line or several. Write each message whole; when several threads or tasks send, write under a lock so lines don’t interleave.
3. Say hello
mochid speaks first:
{"type":"hello","api":1,"version":"0.4.7","module":"hello","settings":{},"data_dir":"…","session_dir":"…","compositor":{…}}
Check api: an SDK for API 1 should refuse anything else with a clear message. Keep module, settings, data_dir, session_dir and compositor for the plugin. Then answer within 5 seconds, or mochid stops the backend:
{"type":"hello","api":1}
4. Number activities and bubbles
The backend picks the ids of its activities and bubbles: count up from 1 and return the number from present and show_bubble, so the plugin can update or remove what it showed. Events about them, like ended or bubble_clicked, carry the same numbers. Activities and bubbles may share one counter.
5. Match answers to questions
call, activate_workspace, windows and pointer_output carry an id, and their answer, call_result or compositor_result, repeats it. Use a second counter for these. Other messages can come before the answer: keep them for later rather than drop them. An async SDK keeps a table of pending ids with a future or callback each; a blocking SDK can read until the answer comes and queue the rest, as the Python one does.
6. Answer every command
A command carries an id, the action and its args as an object, already checked against the manifest. The caller waits until the backend sends a reply with that id: with nothing for success, error for a failure, or output for mochi ipc to print. Make it hard to forget: Rust’s SDK fails a command dropped unanswered, and an SDK with destructors or context managers can do the same.
7. Keep the compositor’s state
compositor messages replace the whole state. Keep the latest for the plugin to read, and let it wait for changes if the language has a way.
8. Stop when mochid closes
When the socket reaches its end, mochid is stopping the plugin: end the event loop, let the plugin finish, and exit. 1.5 seconds later the backend is killed. Fail pending questions then, so nothing waits forever.
9. Let unknown messages through
The protocol only grows: a newer mochid may send message types or fields the SDK doesn’t know. Ignore unknown fields, and pass unknown messages on to the plugin or drop them, but don’t fail on them.
What an SDK should have
- One call per message the backend sends, named like the protocol:
publish_state,present,update,withdraw,show_bubble,update_bubble,hide_bubble,call,reply,activate_workspace,windows,pointer_output. The Rust SDK’s names are the same, which helps people move between them.callreturns theoutputitscall_resultcarries, for actions that answer with something, like a launcher provider’ssearch. - Settings with defaults.
settingsholds only what the user wrote, so the plugin fills in the rest. - A way to wait for events and a timer at once, because most plugins also do something every second or minute: a timeout on the event wait, an async stream, or a callback API on an event loop.
- Activity and bubble specs that need only the view: in the protocol, only
compactandvieware required, and everything else has a default.
A Python SDK
The whole library, about 200 lines with only the standard library:
"""A small Mochi plugin SDK for Python, in one file and the standard library.
It speaks the plugin protocol: JSON lines over the socket mochid passes as
file descriptor 3. Copy this file next to your backend and import it.
from mochi_plugin import Plugin
plugin = Plugin()
for event in plugin.events():
if event["type"] == "command":
plugin.present("Hello", payload={"text": "Hi"}, timeout_ms=3000)
plugin.reply(event)
"""
import json
import os
import select
import socket
import sys
API = 1
class CallError(Exception):
"""Another module's action failed: `kind` is `not_enabled`, `itself`,
`unknown_action`, `invalid_args` or `failed`."""
def __init__(self, error):
self.kind = error.get("kind", "failed")
self.detail = error.get("detail")
super().__init__(f"{self.kind}: {self.detail}")
class Plugin:
"""The connection to mochid. Creating it says hello."""
def __init__(self):
fd = os.environ.get("MOCHI_PLUGIN_FD")
if fd is None:
sys.exit("MOCHI_PLUGIN_FD isn't set: mochid starts plugin backends")
self._socket = socket.socket(fileno=int(fd))
self._buffer = b""
self._backlog = [] # messages read while waiting for an answer
self._next_id = 0 # activities and bubbles
self._next_request = 0 # calls and compositor questions
self.closed = False
hello = self._read()
if hello is None or hello.get("type") != "hello":
sys.exit("mochid didn't start with hello")
if hello["api"] != API:
sys.exit(f"mochid speaks api {hello['api']}, this plugin speaks {API}")
self.module = hello["module"]
self.version = hello["version"]
self.settings = hello.get("settings") or {}
self.data_dir = hello["data_dir"]
self.session_dir = hello["session_dir"]
self.compositor = hello["compositor"]
self._send({"type": "hello", "api": API})
# Events
def events(self, timeout=None):
"""Yields mochid's events as dicts, until it closes the connection.
With `timeout` in seconds, yields None when nothing came for that
long, for work on a timer. Answers and compositor changes are taken
care of here: `self.compositor` is always the latest state."""
while True:
message = self._next(timeout)
if message is None:
if self.closed:
return
yield None
continue
if message["type"] == "compositor":
self.compositor = message["state"]
continue
yield message
def reply(self, command, error=None, output=None):
"""Answers a `command` event: with `error` for a failure, with
`output` for `mochi ipc` to print, or with neither."""
message = {"type": "reply", "id": command["id"]}
if error is not None:
message["error"] = error
if output is not None:
message["output"] = output
self._send(message)
# Requests that need no answer
def publish_state(self, state):
"""Replaces the plugin's state, which its views and other modules read."""
self._send({"type": "publish_state", "state": state})
def present(self, compact, **spec):
"""Submits an activity showing the view `compact`. `spec` takes the
protocol's fields: payload, timeout_ms, priority, expanded, key...
Returns its id."""
number = self._number()
self._send({"type": "present", "id": number, "spec": {"compact": compact, **spec}})
return number
def update(self, activity, payload):
self._send({"type": "update", "id": activity, "payload": payload})
def withdraw(self, activity):
self._send({"type": "withdraw", "id": activity})
def show_bubble(self, view, **spec):
"""Shows a bubble with the view `view`. `spec` takes payload, area,
group, order, priority, news, key, wide. Returns its id."""
number = self._number()
self._send({"type": "show_bubble", "id": number, "spec": {"view": view, **spec}})
return number
def update_bubble(self, bubble, payload):
self._send({"type": "update_bubble", "id": bubble, "payload": payload})
def hide_bubble(self, bubble):
self._send({"type": "hide_bubble", "id": bubble})
# Requests with an answer. They wait for it; events that come meanwhile
# wait in the backlog for `events`.
def call(self, module, action, *args):
"""Runs another module's action and returns what it answered with,
or None. Raises CallError when it fails."""
answer = self._ask({"type": "call", "module": module, "action": action, "args": list(args)})
if answer.get("error"):
raise CallError(answer["error"])
return answer.get("output")
def activate_workspace(self, workspace):
self._compositor({"type": "activate_workspace", "workspace": workspace})
def windows(self):
return self._compositor({"type": "windows"})
def pointer_output(self):
return self._compositor({"type": "pointer_output"})
def _compositor(self, request):
answer = self._ask(request)
if answer.get("error"):
raise RuntimeError(answer["error"])
return answer.get("value")
def _ask(self, request):
self._next_request += 1
request["id"] = self._next_request
self._send(request)
while True:
message = self._read()
if message is None:
raise ConnectionError("mochid closed the connection")
if message["type"] in ("call_result", "compositor_result") and message["id"] == request["id"]:
return message
self._backlog.append(message)
# The wire
def _number(self):
self._next_id += 1
return self._next_id
def _send(self, message):
try:
self._socket.sendall(json.dumps(message).encode() + b"\n")
except OSError:
self.closed = True
def _next(self, timeout):
if self._backlog:
return self._backlog.pop(0)
if b"\n" not in self._buffer and not self.closed:
ready, _, _ = select.select([self._socket], [], [], timeout)
if not ready:
return None
return self._read()
def _read(self):
"""The next message, or None once mochid closed the connection."""
while b"\n" not in self._buffer:
chunk = self._socket.recv(65536)
if not chunk:
self.closed = True
return None
self._buffer += chunk
line, self._buffer = self._buffer.split(b"\n", 1)
try:
return json.loads(line)
except ValueError:
return self._read()
How it does each part:
| Part | In the code |
|---|---|
| Connect | socket.socket(fileno=int(fd)) |
| Lines | _read splits a byte buffer at \n; _send writes json.dumps(message) + "\n" |
| Hello | The constructor reads mochid’s hello, checks api and answers |
| Numbers | _number counts activities and bubbles; _next_request counts questions |
| Answers | _ask reads until its answer comes, keeping other messages in _backlog |
| Commands | reply(event, error=…, output=…) |
| Compositor | events keeps self.compositor up to date and doesn’t yield those messages |
| Stop | events returns when the socket ends |
| Unknown messages | events yields every message it doesn’t handle itself; the plugin skips what it doesn’t know |
| Timers | events(timeout=1.0) yields None when nothing came for a second |
A plugin with it:
#!/usr/bin/env python3
"""An example plugin backend in Python, with the SDK in mochi_plugin.py.
`mochi ipc hello say [text...]` shows the text on the island and counts it
in a bubble. A click on the bubble opens the control center, when it's enabled.
"""
from mochi_plugin import CallError, Plugin
plugin = Plugin()
greeting = plugin.settings.get("greeting", "Hello from Python")
said = 0
bubble = None
plugin.publish_state({"said": said})
for event in plugin.events():
kind = event["type"]
if kind == "command" and event["action"] == "say":
text = event["args"].get("text") or greeting
plugin.present("Hello", payload={"text": text}, timeout_ms=3000)
said += 1
plugin.publish_state({"said": said})
if bubble is None:
bubble = plugin.show_bubble("Bubble", payload={"said": said}, area="right", news=True)
else:
plugin.update_bubble(bubble, {"said": said})
plugin.reply(event, output=f"said {text!r}")
elif kind == "command" and event["action"] == "count":
plugin.reply(event, output=str(said))
elif kind == "command":
plugin.reply(event, error=f"no action {event['action']}")
elif kind == "bubble_clicked":
try:
plugin.call("control-center", "open")
except CallError as error:
# Without the control center there's nothing to open: fine.
if error.kind != "not_enabled":
print(f"opening the control center failed: {error}", flush=True)
and its manifest:
# An example plugin with a backend in Python, and a tiny Python SDK in
# mochi_plugin.py. `needs` asks for Python 3.
[plugin]
id = "hello"
name = "Hello"
version = "0.1.0"
description = "Says hello on the island, from Python"
authors = ["Mochi"]
api = 1
[backend]
exec = "hello.py"
needs = ["python3"]
[[actions]]
name = "say"
description = "Show some text on the island"
args = [{ name = "text", description = "What to say, instead of the greeting", optional = true, rest = true }]
[[actions]]
name = "count"
description = "Print how many times it said something"
# Where its bubble goes unless the user moves it, as hello.py shows it.
[bubbles]
area = "right"
The backend is the script itself, so Python must be installed where the plugin runs. A plugin can ship its SDK file next to its code, as this one does, or depend on a package.
Testing an SDK
Test the SDK the way mochid uses it: make a socket pair, give one end to the SDK, and play mochid on the other, sending hello first. Check that it answers hello, numbers what it shows, matches answers to questions with other messages in between, answers commands, and ends when you close your end. Rust’s SDK does this in crates/mochi-sdk/tests/talk.rs, and the Rust SDK page shows it.
Then run a plugin built with it in a real mochid: list it in plugins.toml with a path: source, enable it, and drive it with mochi ipc. mochi status says whether it runs, and mochid’s log has what it printed. crates/mochid/tests/plugins.rs does the same automatically for the Python example and for a backend in sh.
Launcher providers
A plugin can add results to the launcher: an emoji picker, bookmarks, a password manager, anything you’d search for. The launcher asks the plugin’s backend with each query and shows what it answers, under the plugin’s heading. For results from a script, without a plugin, see script providers.
The emoji picker in examples/plugins/emoji is a complete one: ;cat lists cats, Enter copies the one you pick, and the ones you picked come first next time. Mochi’s own emoji module is built the same way, with :.
The contribution
A provider is a contribution to the launcher, without a view:
[[contributions]]
target = "launcher"
kind = "provider"
id = "emoji-example"
title = "Emoji"
options = { prefix = ";", search = "search", pick = "pick" }
[[actions]]
name = "search"
description = "Search emoji by name"
args = [{ name = "query", kind = "string", optional = true, rest = true }]
[[actions]]
name = "pick"
description = "Remember an emoji the user picked"
args = [{ name = "id" }]
| Option | ||
|---|---|---|
prefix | A query starting with it asks only this provider, with the rest. Without one, the provider is asked on every query that isn’t empty, next to the apps. When prefixes overlap, the longest wins; one can end with a space, like the timer’s :t , so :tea still goes to the emoji’s : | |
search | "search" | The action that answers a query. It takes the query as one optional rest argument. |
pick | An action taking a result’s id, called after the user picks a result that has one. |
id names the provider in the launcher’s settings, so users can change its prefix, its order or its heading, or turn it off, with a [module.launcher.providers.<id>] section. The contribution’s order is where it goes by default; apps are at 0.
Answering
The launcher calls the search action as mochi ipc would, a moment after the user stops typing, and reads the answer: one result per line, as JSON. In the Rust SDK, answer with command.answer:
#![allow(unused)]
fn main() {
ModuleEvent::Command(command) if command.action == "search" => {
let query = command.args.str("query").unwrap_or("");
let lines: Vec<String> = find(query)
.map(|emoji| {
json!({
"title": emoji.name,
"subtitle": emoji.group,
"glyph": emoji.glyph,
"copy": emoji.glyph,
"id": emoji.glyph,
})
.to_string()
})
.collect();
command.answer(Ok(lines.join("\n")));
}
}
A result is the same as a script provider’s: a title, and optionally a subtitle, an icon, a glyph or a color, at most one of copy, type, open and run for what Enter does, an alt with what Shift+Enter does, an id, and a file the result drags out as. A result with only an id leaves everything to pick, which can then do whatever the plugin wants. Answer with nothing for no results; an error is logged and shows no results.
The launcher asks at once, on every keystroke, so answer quickly. Answers to a query the user has typed past are dropped, so a slow provider never shows stale results. Keep the answer under 50 results; the launcher cuts the list at its max_results.
Picking
When the user picks a result with an id, the launcher does the result’s verb, closes, and calls the pick action with that id. The emoji picker uses it to put recently picked emoji first.
Taking contributions yourself
The launcher learns about providers from ModuleEvent::Offers: every module gets the contributions whose target is its id, at the start and after each reload that changes them. A plugin can take contributions the same way, for things other plugins add to it.
Writing widgets
Any module or plugin can offer widgets for the desktop. A widget is a view, offered with a contribution to the widgets module; users place it as many times as they like, and each placed one, an instance, has its own id and settings.
The contribution
In a plugin’s manifest:
[[contributions]]
target = "widgets"
kind = "widget"
id = "countdown"
view = "Countdown"
title = "Countdown"
icon = "clock"
options = { size = [12, 6], min = [8, 4], max = [24, 12], category = "Calendar",
description = "The days left until a date", settings = [
{ name = "label", default = "Holidays", description = "What it counts down to" },
{ name = "date", default = "2026-12-20", description = "The day, as YYYY-MM-DD" },
{ name = "big", kind = "bool", default = false, description = "Only the number" },
] }
A builtin module returns the same as a ContributionSpec from Module::contributions, with the options as JSON.
| Option | Default | |
|---|---|---|
size | [12, 8] | The size it’s added at, in grid cells |
min, max | [2, 2], [200, 120] | How small and large users can make it |
frame | true | Whether Mochi draws the card behind it. false for a widget that floats on the wallpaper |
settings | [] | What users can set for each instance: name, kind (string, int, float, bool or choice with choices), default and description. The editor makes a form from them. A text setting with source = "timezone" gets a menu of the system’s time zones as users type in it |
forget | An action the module runs with an instance’s id when the user removes it, to drop what it kept for it | |
category | the module’s name | What the drawer groups it under, like Clock or System. Widgets of several modules can share one |
places | ["desktop", "lock"] | Where it may go: desktop, lock for the lock screen, or both. On the lock screen it only shows: it never gets a key, and its commands don’t run. A plugin’s goes there only when the user sets lock_plugins |
required | false | It can’t be removed from where it goes, like the lock screen’s password field |
description | One line on what users see, for the drawer’s card, like “The cover beside the track, with its controls”. Plain words, under about 50 characters, so it fits two lines | |
variants | [] | Its looks; see below |
Variants
A widget can have several looks, like a clock that’s digital, stacked or analog. Each is a variant: the drawer shows a card for each, users pick one there and can change it in the widget’s settings, and the placed widget records it in widgets.toml.
options = { size = [14, 7], min = [8, 4], category = "Clock", settings = [
{ name = "seconds", kind = "bool", default = false, description = "Show the seconds" },
{ name = "hand", default = "", description = "A color for the second hand" },
], variants = [
{ id = "digital", title = "Digital", description = "The time, big, over the date" },
{ id = "stacked", title = "Stacked", description = "Hour above minute, like a headline",
size = [9, 12], min = [6, 8], settings = ["seconds"] },
{ id = "analog", title = "Analog", description = "Hands and ticks on a round face",
view = "Analog", size = [12, 12], min = [8, 8], max = [30, 30] },
] }
| Key | ||
|---|---|---|
id | required | One word, without a colon: widgets.toml and add <module> <widget>:<id> name it |
title | required | Its name on the card and in the settings, like “Stacked” |
description | "" | One line on what users see; the card shows it instead of the widget’s |
view | the widget’s | A view of its own, for a look that shares little with the others |
size, min, max | the widget’s | Its sizes; a widget switched to it takes its size |
frame | the widget’s | Whether Mochi draws the card behind it, so one look can float on the wallpaper, like the minimal clock |
settings | all of them | The names of the widget’s settings that apply to it; the form leaves out the others |
defaults | none | Defaults of its own for some of the widget’s settings, like { shape = "none" } for a look that offers the shape setting but starts without one |
The first variant is the default: a widget placed before its widget had variants, or placed with one its widget no longer offers, gets it. So when you add looks to a widget that had one, describe the look it has now first, and add the others after it. A widget with variants keeps one description per variant, and doesn’t need its own.
Adding a look is one more entry in variants and, when it doesn’t name a view of its own, one more branch in the view that reads variant. A look’s settings keep their values when the user switches to another look, so a view reads only the ones its look lists: the stacked clock leaves seconds alone even when the digital one had it on.
The builtin looks use pieces from the core, in qs.island: ExpressiveShape, a circle, pentagon, cookie, clover, burst, hexagon, octagon, squircle or pill to set one thing apart; WavyRing, how full something is as a ring; WavyProgress, a progress line that waves while something plays; and StackedTime, a big clock’s hour over its minutes. A shape is an accent: one per widget, behind the thing that matters, like today on the calendar.
The view
The view fills the widget, inside the card’s padding when it has a card. It gets:
| Property | |
|---|---|
payload | The offering module’s published state, as control center cards get it |
settings | This instance’s settings, with the defaults filled in, for a view that declares property var settings |
instance | This instance’s id, like w3, or preview in the drawer’s cards, for a view that declares property string instance |
variant | The id of its look, for a view that declares property string variant |
Only payload is there in Component.onCompleted. The others come right after the view is made, before it first draws, so bind to them rather than reading them once there.
import QtQuick
import qs.island
Item {
property var payload: null
property var settings: ({})
property string instance: ""
Text {
anchors.centerIn: parent
text: settings.label
color: Theme.foreground
font.pixelSize: Math.min(parent.height * 0.4, Theme.textDisplay)
}
}
A view with looks declares property string variant: "" and picks what to draw from it, with the first look for "":
Item {
property var payload: null
property var settings: ({})
property string instance: ""
property string variant: ""
readonly property bool stacked: variant === "stacked"
}
Size text from the widget’s size, since users resize it. The drawer shows the real view, with the module’s real state and the default settings, scaled down and taking no clicks, as the preview on each card, with instance set to preview: a view keeping content per instance shows none there. Set property bool hidden: true to step aside while there’s nothing to show; the widget comes back in edit mode, and the drawer’s card says there’s nothing to show right now. A view with a text field sets property bool typing: true: the desktop then takes the keyboard when the user clicks into it, and gives it back on a click elsewhere. Let Escape take the focus off the field.
A control center card’s view often works as a widget as is: media and battery offer their cards both ways.
Instance content
A widget that keeps content per instance, like a note’s text, keeps it in its module, keyed by instance: it publishes it in its state, by instance, and its view changes it with actions that take the instance’s id, like Daemon.command("notes", "write", [instance, text]). Name an action in forget to drop an instance’s content when the user removes it.
Mochi protocol
mochid talks to the Quickshell UI and to the mochi CLI over one Unix socket. The Rust definitions live in crates/mochi-protocol, and this page describes the conversation they implement.
Transport
- The socket is
$XDG_RUNTIME_DIR/mochi/mochi.sock. The daemon passes the path to Quickshell inMOCHI_SOCKET. - Each message is one JSON object followed by
\n. Lines longer than 1 MiB are rejected. - Every object has a
typefield naming the message in snake_case. - The current API version is
1.
Handshake
The first message on every connection is the client’s hello:
{"type":"hello","api":1,"role":"ui"}
role is ui for Quickshell and ctl for the CLI and other control clients. The daemon answers with its own hello:
{"type":"hello","api":1,"version":"0.4.7"}
If the API versions differ, the daemon answers with an unsupported_api error and closes the connection. Any other message before hello gets a hello_first error and the connection closes.
UI connections
After the handshake, the daemon sends the UI everything it needs to draw, in this order:
modules, the enabled modules.contributions, what modules offer each other.theme, the design tokens.- One
stateper module that has published state. present, what the island shows now.bubbles, every bubble.
After that, the daemon pushes those messages again whenever they change. A reconnecting UI gets the full set again, so it never has to keep state across restarts.
The UI sends event messages, which the daemon never answers:
{"type":"event","activity":7,"kind":"click"}
kind is click, hover_enter, hover_leave, dismiss or outside, a click outside the island. Events name the activity they happened on. The daemon ignores events for an activity that is no longer shown, because they arrive while the island switches views.
A click on a bubble is a bubble_click, also never answered. The daemon passes it to the bubble’s module and drops clicks on bubbles that are gone:
{"type":"bubble_click","bubble":12}
A click on an area’s “+N” pill is an overflow_click, never answered either. The daemon shows the area’s hidden bubbles in the island as an activity of its own, from the module mochi, with the view HiddenBubbles and the payload {"area", "bubbles"}, where bubbles are the hidden ones in the shape bubbles uses. The UI loads the views of module mochi from root:/island/<view>.qml. No plugin may take the id mochi.
{"type":"overflow_click","area":"right"}
The UI may also send command to run module actions, for example from a button in a view.
Control connections
Control clients send one request at a time and read exactly one answer before sending the next.
| Request | Answer |
|---|---|
{"type":"command","module":"osd","action":"volume","args":["+5"]} | ok or error |
{"type":"status"} | status |
{"type":"reload"} | ok or error |
{"type":"dismiss"} | ok: closes what the island shows, as a right click does |
{"type":"list_actions"} or {"type":"list_actions","module":"osd"} | actions |
{"type":"step_aside","pid":1234} | ok, then the daemon stops its shell and modules, waits for process 1234 to end and starts again. a dev daemon sends it to take over the session |
{"type":"profile","seconds":30} | output, the report’s path, once the recording ends and the report is written: what mochi profile sends. invalid_args outside 1 to 300 seconds |
Command arguments are always strings, as typed on the command line. The daemon checks them against the action’s declared arguments before the module sees them, and answers invalid_args with a usage line when they don’t fit.
Messages
Client to daemon
| Type | Fields | Sent by |
|---|---|---|
hello | api, role | everyone, first |
command | module, action, args (optional, defaults to []) | UI and control |
event | activity, kind, output (optional), click (optional, for outside: output, x, y, width, height, button, and scroll {x, y} for a scroll) | UI |
pass_on | click, as in event: a scroll the island caught without closing anything, which the daemon passes on | UI |
bubble_click | bubble | UI |
overflow_click | area | UI |
status | control | |
reload | control | |
dismiss | control | |
list_actions | module (optional) | control |
step_aside | pid | control |
profile | seconds | UI and control |
frames | output, surface (island or desktop), frames: how many frames that window drew in the last second, while the daemon profiles | UI |
Daemon to client
| Type | Fields | Sent to |
|---|---|---|
hello | api, version | everyone |
modules | modules | UI |
contributions | contributions | UI |
state | module, state (any JSON) | UI |
live | module, value (any JSON): a value that changes many times a second, like an audio meter’s level. The daemon doesn’t keep it, so a reconnecting UI doesn’t get it again | UI |
present | activity (object or null), output (optional), resting (optional) | UI |
bubbles | bubbles, overflow (optional) | UI |
theme | theme | UI |
covered | outputs: the monitors a fullscreen window covers, by name; desktops: those whose desktop windows hide, which hides the desktop widgets there but not the island. Sent after hello and whenever either changes; views there stop what only decorates, like a wave | UI |
profiling | on: whether the daemon profiles now. While it does, the UI counts the frames each window draws and sends frames every second. Sent after hello and whenever it changes | UI |
ok | whoever sent command or reload | |
output | output: what the command says, like the share picker’s choice | whoever sent command or profile |
status | status: version, api, ui_connected, modules, compositor (backend, outputs, workspaces), plugins (each id, state and an optional message; left out without plugins) | control |
actions | modules: list of {module, actions} | control |
error | code, message | everyone |
reload_views | UI: a module was turned on and the shell directory has its views. The UI reloads them in place, keeping its windows, then connects and says hello again. One that doesn’t within a few seconds gets a fresh Quickshell. |
Activity
Each monitor has an island of its own. present carries what one island shows, and output names its monitor; after hello the daemon sends one for every monitor. Without output, the activity is for every island, as before the compositor names its monitors. resting is only for UIs of earlier releases, which had one island mirrored on every monitor; the daemon no longer sends it. An event names in output the island it happened on, so a click expands the activity on that monitor only. An outside event carries the click that closed the activity, on whichever monitor it happened, in that monitor’s logical pixels, with Qt’s button (1 left, 2 right, 4 middle); once the activity is gone, the daemon clicks there again through a virtual pointer, so the window under it gets the click.
present carries the activity on screen:
{
"type": "present",
"activity": {
"id": 7,
"module": "notifications",
"view": "Compact",
"payload": {"title": "Hello"},
"expanded": false,
"expandable": true,
"key": "group-42"
}
}
The UI loads root:/modules/<module>/<view>.qml and passes payload to it. activity is null only when no module has anything to show, not even the idle pill.
modal is only present when true. A modal activity takes the keyboard while it’s shown, for views you type into like the launcher, and the UI dismisses it on a click outside the island or Escape. The daemon also marks an activity modal while the user has it expanded with a click.
overlay is only present when the module set one, and implies modal. It names a second view, root:/modules/<module>/<overlay>.qml, which the UI draws full-screen on every monitor, under the island, while the activity shows. The overlay gets the same payload and a screen property with its monitor. If it has a ready property, the island waits for it to turn true before showing the activity, so an overlay can freeze the screen before the island changes. Overlays are for picking something on screen, like the capture module’s region.
output in an activity is only present when it’s meant for one monitor, from [island] panels, notices or the module itself. It’s the same as the present’s.
outside is only present when true: a click outside the island closes the activity, so the UI catches every click while it shows and sends an outside event. modal implies it.
over_fullscreen is only present when true: the activity shows over a fullscreen window, like a game, which hides the island otherwise. Modal activities, and those with an overlay, show there anyway without it. Over a fullscreen window the UI draws only such an activity, not the bubbles or what the island showed before, and an activity that isn’t modal doesn’t catch clicks there, so they reach the window.
key is only present when the module set one. A module uses it to replace its own activity, for example a volume OSD on every volume step. When the next present has the same module, key and view as the shown activity, the UI updates the view’s payload in place instead of switching views, even though the id is new.
Bubbles
bubbles lists every bubble on screen, in drawing order: the five areas from left to right (left, center-left, center, center-right, right), and within each area from left to right. The daemon has already applied the user’s placement from config.toml, the sort order and the per-area maximum.
{
"type": "bubbles",
"bubbles": [
{"id": 12, "module": "media", "key": "media", "view": "BubbleWide", "wide": true, "payload": {"title": "Song"}, "area": "center-left"},
{"id": 14, "module": "bluetooth", "view": "Battery", "payload": {"percent": 80}, "area": "right", "group": "status"},
{"id": 15, "module": "volume", "view": "Level", "payload": {"percent": 40}, "area": "right", "group": "status"}
],
"overflow": [{"area": "right", "hidden": 2}]
}
Consecutive bubbles in the same area with the same group share one pill. A bubble’s view is small, about 26 pixels, and drawn in a circle, unless wide is true: then the user asked for the module’s wide view, drawn in a pill. key and group are only present when set, and wide only when true. As with activities, a bubble with the same module, key and view as one already drawn continues it: the UI updates its payload in place. overflow names the areas that left bubbles out, and how many; it is left out when nothing was.
Contributions
contributions lists what every enabled module offers other modules, like the control center’s cards and pages. Modules declare them up front, so the list doesn’t change while the daemon runs.
{
"type": "contributions",
"contributions": [
{"module": "media", "target": "control-center", "kind": "card", "id": "now-playing", "view": "Card", "title": "Now playing", "order": 10, "options": {"span": 2}}
]
}
target is the module meant to use it, and kind is one of the kinds that module takes. The target’s view loads root:/modules/<module>/<view>.qml and passes it the offering module’s latest state as payload. icon and options are only present when set. A contribution to a module that isn’t enabled is simply unused.
The shell itself takes contributions as mochi, which is always there. Its one kind is preload: a view the UI compiles a few seconds after it starts, one at a time and off the UI thread, so the first time it shows, like the settings panel, it only has to build it. With {"offered": ["card", "page"]} in options, the views other modules offer the preloading module as those kinds compile too.
Action descriptions
actions lists what mochi ipc can run:
{
"name": "volume",
"help": "Change the volume",
"args": [
{"name": "delta", "help": "Percent to add", "kind": {"type": "int"}, "optional": false, "rest": false}
]
}
kind.type is string, int, float, bool or choice. A choice also has values. An optional argument may be left out, and only trailing arguments can be optional. A rest argument takes every remaining word, joined with spaces, and only the last argument can be rest.
Error codes
| Code | Meaning |
|---|---|
bad_message | The line was not a valid message. |
hello_first | Something other than hello arrived first. |
unsupported_api | The client speaks another API version. |
not_allowed | The connection’s role may not send this message. |
unknown_module | No enabled module has this id. |
unknown_action | The module has no such action. |
invalid_args | The arguments don’t match the action. The message includes a usage line. |
module_failed | The module accepted the command and then reported a failure, or isn’t running. |
invalid_config | reload found an error in a config file. The message names the file and the key. |
internal | A daemon bug. |
Plugin backends
A plugin’s backend talks to mochid over a connection of its own, not the main socket. mochid starts the backend with one end of a socket pair as file descriptor 3, named in MOCHI_PLUGIN_FD, and the plugin’s directory in MOCHI_PLUGIN_DIR, which is also its working directory. Messages are the same JSON lines. What the backend prints on stdout and stderr goes to mochid’s log.
mochid speaks first:
{"type":"hello","api":1,"version":"0.4.7","module":"pomodoro","settings":{"focus_minutes":25},"data_dir":"/run/user/1000/mochi/data/pomodoro","session_dir":"/run/user/1000/mochi/session/pomodoro","compositor":{"backend":"wayland","outputs":[],"workspaces":[]}}
settings is the plugin’s [module.<id>] table from config.toml. The backend answers within 5 seconds with the API version it speaks, or mochid stops it:
{"type":"hello","api":1}
From then on, either side may send at any time. The backend picks the numbers of its activities and bubbles, and events about them use those numbers. The backend should exit when mochid closes the socket; after 1.5 seconds it is killed.
Backend to daemon
| Type | Fields | Does |
|---|---|---|
publish_state | state | Replaces the plugin’s state, which views and other modules read |
present | id, spec | Submits an activity: see below |
update | id, payload | Replaces an activity’s payload |
withdraw | id | Removes an activity |
show_bubble | id, spec | Shows a bubble, or replaces the one with the same key |
update_bubble | id, payload | Replaces a bubble’s payload |
hide_bubble | id | Removes a bubble |
reply | id, output (optional), error (optional) | Answers a command |
call | id, module, action, args | Runs another module’s action; answered with call_result |
activate_workspace | id, workspace | Answered with compositor_result |
windows | id | The windows on visible workspaces; answered with compositor_result |
pointer_output | id | The output under the pointer; answered with compositor_result |
An activity spec needs only compact, the view’s name. The rest are optional: expanded, expand_for_ms, payload, priority (0 to 255, 50 by default), timeout_ms, interruptible (true by default), same_priority (queue or stack), modal, overlay, passive, fleeting, over_fullscreen, output and key. A bubble spec needs only view; the rest are wide, payload, area, group, order, priority, news and key. They mean what the builder methods of the same name in mochi-sdk do.
Daemon to backend
| Type | Fields | Means |
|---|---|---|
command | id, action, args | An action to run, with args checked against the manifest, as an object like {"minutes": 5}. Answer with reply and the same id |
clicked | activity | A click on an activity without an expanded view |
hovered | activity, hovered | The pointer came onto an activity on the island (true), or left it or the island stopped showing it (false) |
ended | activity, reason | An activity is gone: expired, dismissed, withdrawn, replaced or outside |
bubble_clicked | bubble | A click on a bubble |
state | module, state | A module from the manifest’s [uses] state published state; null when it stopped |
compositor | state | The compositor’s state changed |
offers | offers | What other modules offer this plugin: every contribution whose target is its id, like launcher providers for a plugin that is a launcher. Sent at the start, then when a reload changes it |
call_result | id, output (optional), error (optional) | output is what the action answered with; error is {"kind": "not_enabled", "detail": "media"} and the like |
compositor_result | id, value, error (optional) |
A backend that exits with an error is started again after 250 ms, then after twice as long each time, up to 8 seconds. After 5 crashes within a minute it stays stopped until mochi reload, and a desktop notification says so.
Changing the protocol
The protocol only grows. Adding a message type or adding a field with a default keeps API version 1. Removing or renaming a message or field, or changing what a field means, requires a new API version.