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.