Mousr documentation
Mousr controls the pointer from the keyboard on Sway. It provides grid selection, mouse movement, clicks, drags, and scrolling.
Mousr runs as a Rust daemon. It uses Wayland protocols for outputs, overlays, keyboard capture, and pointer events. It uses Sway IPC for the focused output, cursor warps across outputs, and pointer actions when the virtual pointer protocol is unavailable.
Mousr currently supports Sway on Wayland only.
Requirements#
- A Wayland session running Sway.
- The Wayland client and
libxkbcommonruntime libraries. Distribution packages install them. - For focus preservation, compositor support for
zwp_input_method_manager_v2. - For the refinement lens, compositor support for screencopy.
Installation#
Packages are available for Ubuntu, Debian, Fedora, and Arch Linux. Prebuilt amd64 and arm64 archives and cargo install mousr are also available.
See the installation commands.
Quick start#
Add these lines to the Sway configuration:
exec mousr daemon bindsym Mod1+space exec mousr grid bindsym Mod1+Shift+space exec mousr mouse
Run swaymsg reload. Press Alt+Space to open the grid, type a label such as fk, and press s to left-click the cell.
To change settings, copy the example configuration to ~/.config/mousr/config.toml and run mousr reload.
Grid mode#
mousr grid covers the focused output with a grid of labelled cells and captures the keyboard.
- Type a label. Labels are fixed-width base-26 strings:
atoz, thenaatozz. Cells that no longer match are dimmed.grid.unmatchedcontrols this. - Refine. A complete label selects the cell. Return subdivides it. BackSpace erases a character or returns one level.
- Act. Press an action key. Mousr moves the pointer to the cell centre and performs the action.
How cells are sized
The first level is derived from the output size and grid.root_min_tile_width × grid.root_min_tile_height The default is 96 × 54. Each refinement halves both targets until min_tile_width and min_tile_height are reached, then coarsens the level if needed to fit label capacity and max_cells.
With grid.refinement_zoom above 1.0, Mousr captures a fresh output image on each descent and draws the selected rectangle magnified inside a lens. The area outside the lens is dimmed. Minimum tile sizes then apply to the magnified display space. If screencopy is unavailable, refinement continues without the lens.
ui.lens_animation_ms sets the duration of the transition between levels. Keyboard input ends the transition.
Mouse mode#
mousr mouse, or g from a grid selection, starts continuous keyboard pointer control.
- Movement. Hold h j k l. Speed starts at
motion.initial_speedand ramps towardmotion.max_speedalongmotion.curve. Fractional motion is preserved, so movement below one logical pixel per update is possible. - Buttons. s d f mirror key state for left, middle, and right. Hold one while moving to drag. Pressing s twice performs two left clicks; c sends an explicit double-click.
- Button lock. Press v, then a button key, to hold that button without a chord. Press v again to release it.
- Exit. Escape releases all held buttons and exits.
Scrolling#
u e y o scroll up, down, left, and right in grid and mouse mode. 15 units equal one wheel notch.
For your own bindings, mousr scroll up|down|left|right [--step AMOUNT] scrolls once. By default it targets the surface under the pointer. With scroll.target = "focused-window", it moves the cursor to the centre of the focused window's content first and leaves it there.
The virtual-pointer path sends the continuous amount with a discrete notch count rounded to the nearest whole notch, with a minimum of one. The Sway IPC fallback emits whole notches only.
Multiple outputs#
By default the grid covers the output containing Sway's focused workspace. Use --scope all to span every output with unique labels, or --output NAME to target one. Relative mouse motion uses the compositor's global logical coordinate space, so it crosses outputs according to your Sway or wlr-randr layout.
If a display or keyboard disappears during suspend/resume, the active mode is cancelled and held buttons are released. The keyboard is rebound when the seat returns.
CLI reference#
All commands except daemon are short-lived clients of the running daemon.
The local target/debug/mousr build identifies as mousr-dev and uses a
separate IPC socket, so it can be tested alongside an installed release daemon.
mousr [GLOBAL OPTIONS] daemon [--config PATH] [--seat NAME] mousr [GLOBAL OPTIONS] reload mousr [GLOBAL OPTIONS] cancel mousr [GLOBAL OPTIONS] grid [OPTIONS] mousr [GLOBAL OPTIONS] mouse mousr [GLOBAL OPTIONS] click left|middle|right mousr [GLOBAL OPTIONS] scroll up|down|left|right [--step AMOUNT]
Global options may appear before or after the subcommand:
| Option | Meaning |
|---|---|
--log-level LEVEL | error, warn, info, debug, or trace; default: info. |
--log-file PATH | Also append JSON-lines logs to PATH, creating parent directories. |
Stderr uses compact DBG, INF, WRN, ERR, and PNC prefixes with UTC
timestamps. Logging is process-local; use mousr --log-level debug daemon to
debug the daemon.
daemon
Starts the long-running Wayland backend and Sway focus resolver.
| Option | Meaning |
|---|---|
--config PATH | Use PATH instead of the default configuration file. |
--seat NAME | Use a named Wayland/Sway seat; default: seat0. |
Only one daemon may run per WAYLAND_DISPLAY. Its mode-0600 IPC socket is
created under XDG_RUNTIME_DIR. If the Wayland keyboard or an output
disappears during suspend/resume or display reconfiguration, the daemon cancels
the active mode and releases held buttons; it rebinds the selected keyboard
when the seat becomes available again.
grid
Displays a labelled grid and captures keyboard input.
| Option | Values | Meaning |
|---|---|---|
--scope | focused, all | Override the configured output scope. |
--output | output name | Target one active Wayland output. |
--action | action below | Run an action when a label is selected. |
--auto-descend | — | Descend automatically when another level fits. |
--no-auto-descend | — | Disable automatic descent. |
--max-depth | u8 integer | Override the configured recursion limit. |
--scope and --output are mutually exclusive. focused means the output
containing Sway's focused workspace. With all, labels remain unique across
outputs.
Actions:
| Action | Result after selection |
|---|---|
choose | Wait for a grid-mode action key. This is the default. |
move | Move to the cell centre and exit. |
mouse | Move to the cell centre and enter mouse mode. |
left, middle, right | Move, click that button, and exit. |
double-click | Move, double-click the left button, and exit. |
scroll | Move and enter persistent scroll mode. |
scroll-up, scroll-down | Move and scroll vertically; exit only if grid.exit_on_scroll is enabled. |
scroll-left, scroll-right | Move and scroll horizontally; exit only if grid.exit_on_scroll is enabled. |
Persistent scroll mode uses the configured mouse scroll keys (u, e, y,
and o by default). Exit with the mouse cancel key (Escape by default).
Default grid keys:
| Keys | Action |
|---|---|
a–z | Enter a label. |
s, d, f | Left, middle, or right click. |
c | Double-click the left button. |
u, e, y, o | Scroll up, down, left, or right. |
g | Enter mouse mode. |
Space | Move to the selected cell and exit. |
Enter | Descend into the selected cell. |
Backspace | Erase a character or return one level. |
Escape | Cancel. |
mouse
Starts continuous keyboard pointer control.
mousr mouse [--until-release KEY]
--until-release KEY ends the session when that key is released, even while
movement or button keys are held. Exit stops movement and releases all held or
locked mouse buttons. The named key is reserved for session lifetime; its
presses and repeats do not trigger mouse actions. Escape and mousr cancel
still exit normally. Without this option, behavior is unchanged.
On Wayland, use a case-sensitive XKB keysym
name such as
F24, Control_L, or Alt_L. That reference lists every valid name; drop the
XKB_KEY_ prefix it displays. The daemon resolves it against the current seat's keymap and tracks the physical
keycodes, so changing modifiers while holding the key does not affect release
matching. If several physical keys produce the same keysym, releasing any of
them ends the session; use a uniquely mapped key for a dedicated activation key.
Unknown names and unmapped keys are rejected. A keymap change cancels a
release-controlled session. Repeating the same release-controlled mouse command
while it is active preserves movement and held buttons.
For a dedicated key mapped to F24, use one Sway press binding:
bindsym --no-repeat F24 exec mousr mouse --until-release F24
Remove the corresponding Sway --release binding: Mousr handles release during
the session. This command uses the existing daemon; it does not register a
global shortcut or synthesize a keypress.
Release-controlled Wayland sessions require an input-method v2 keyboard grab,
even with general.preserve_focus = false: Sway's ordinary focused-keyboard
path can omit releases whose presses were consumed by a shortcut. These
sessions preserve application focus and fail activation if the grab is
unavailable or already occupied by another input method.
Input handoff limitation: a release that happens before Mousr acquires keyboard
input cannot be recovered reliably from Wayland's input-method protocol. Sway's
focus snapshot also excludes shortcut-consumed keys. An extremely quick tap
can therefore leave mouse mode active; use Escape or mousr cancel to exit.
This option observes release events; it does not query global held-key state.
| Default keys | Action |
|---|---|
h, j, k, l | Move left, down, up, or right. |
s, d, f | Hold/release left, middle, or right button. |
c | Double-click the left button. |
v then s, d, or f | Lock a button; press v again to release it. |
u, e, y, o | Scroll up, down, left, or right. |
Escape | Release held buttons and exit. |
Button keys mirror key state. Button lock provides dragging without a keyboard
chord. Pressing s twice also performs two left clicks.
One-shot commands
mousr click left|middle|right mousr scroll up|down|left|right [--step AMOUNT]
click presses and releases the chosen button. scroll emits the chosen wheel
direction. --step overrides its configured amount; 15 units equal one notch.
Both commands cancel the active session and release held mouse buttons before
performing their action. click uses the current pointer location.
Direct scrolling targets the current pointer by default. With
[scroll] target = "focused-window", it moves the cursor to the focused window's
content center, scrolls there, and leaves the cursor there. Grid and mouse mode
scrolling are unaffected.
Lifecycle commands
mousr reloadvalidates and applies the daemon configuration. A rejected configuration leaves the previous configuration in place but cancels the active session. Changinggeneral.preserve_focusalso cancels the session. If redrawing fails after application, the new configuration remains applied and the session is cancelled.mousr cancelexits the active mode and releases held mouse buttons.mousr --helpprints command syntax.mousr --versionprints the version.
Version output is <name> v<version>(<short-commit>), for example
mousr v0.1.1(1a2b3c4d) or mousr-dev v0.1.1(1a2b3c4d).
Default keybindings#
| Mode | Keys |
|---|---|
| Grid labels | a to z select cells |
| Grid actions | s d f left/middle/right click · c double-click · u e y o scroll · g mouse mode · Space move |
| Grid navigation | Return descend · BackSpace back · Escape cancel |
| Mouse movement | h j k l left/down/up/right |
| Mouse buttons | Hold s d f for left/middle/right · c double-clicks left · combine with movement to drag |
| Button lock | v then s d f locks a button · v releases it |
| Mouse scrolling | u e y o up/down/left/right |
| Mouse exit | Escape releases held buttons and exits |
Configuration#
Mousr reads $XDG_CONFIG_HOME/mousr/config.toml, falling back to
~/.config/mousr/config.toml. Pass mousr daemon --config PATH to use another
file. Unknown keys and invalid values are errors. mousr reload applies a valid
replacement without restarting the daemon.
General
| Option | Default | Meaning |
|---|---|---|
general.scope | "focused" | Initial grid scope: focused or all. |
general.preserve_focus | false | Keep application keyboard focus while Mousr is active, using Wayland input-method v2. |
focused means the output containing Sway's focused workspace. CLI
--scope overrides the default; --output NAME targets one exact output.
With preserve_focus = false (the default), Mousr focuses its overlay and requires
compositor shortcut inhibition. With preserve_focus = true, grid, mouse, and
interactive scroll sessions keep the overlays unfocusable. This can preserve menus and popovers that close
when their application loses keyboard focus. Mousr acquires the input-method
slot only during a session and releases it on exit. The compositor must support
zwp_input_method_manager_v2, and the selected seat must not already have an input
method such as Fcitx5 using that protocol. Activation fails if capture is
unavailable; Mousr never falls back to taking focus.
With focus preservation enabled, compositor shortcuts
remain active and can intercept keys before Mousr receives them. Normal keyboard
input is captured only while a session is active. Pointer movement, clicks, and
focus_follows_mouse can still change the focused window, and scrolling still
targets the surface under the pointer. Focus preservation does not remove the
existing Sway dependency for output selection, cursor warps, or pointer fallbacks.
Changing preserve_focus with mousr reload cancels the current session
and applies the new input policy to the next activation.
Existing configurations
general.require_shortcut_inhibit is deprecated but remains accepted with a
warning. Existing true values retain the default requirement for inhibition;
existing false values retain permissive operation, which requests inhibition
but allows the overlay to take focus even if inhibition is unavailable.
Remove a legacy true entry to keep the same behavior. A legacy false entry
has no exact replacement: remove it to require inhibition, or replace it with
preserve_focus = true to select a different input path that preserves focus.
Configurations explicitly containing both keys are rejected, including when
either value is false; remove require_shortcut_inhibit before setting
preserve_focus. Mousr does not rewrite existing configuration files.
Grid
| Option | Default | Meaning |
|---|---|---|
grid.root_min_tile_width | 96 | Minimum logical cell width for the first grid level. |
grid.root_min_tile_height | 54 | Minimum logical cell height for the first grid level. |
grid.min_tile_width | 16 | Minimum displayed recursive cell width; magnified source cells may be smaller. |
grid.min_tile_height | 16 | Minimum displayed recursive cell height; magnified source cells may be smaller. |
grid.refinement_zoom | 1.0 | Magnification applied to the selected rectangle at each recursive level; 1.0 disables the lens. |
grid.max_label_length | 3 | Maximum base-26 label length, from 1 through 4. |
grid.max_depth | 4 | Maximum recursive selection depth. |
grid.max_cells | 4096 | Hard cell-count and rendering-work limit. |
grid.auto_descend | false | Descend immediately after selecting a cell when possible. |
grid.exit_on_scroll | false | Exit grid mode after a directional scroll action. |
grid.unmatched | "dim" | Render unmatched cells as keep, dim, or hide. |
grid.unmatched_opacity | 0.18 | Opacity used by dim, from 0 through 1. |
Mousr derives the first grid level from output size and the root minimum tile
size. Each refinement halves the width and height targets independently until
the finest min_tile_* values are reached, then coarsens the level if needed
to fit label capacity and max_cells. With refinement_zoom greater than
1.0, Mousr opens the root grid without a screenshot, then captures a fresh
output image for each magnified descent. The minimum tile dimensions then apply to
the magnified display space, so smaller source-coordinate cells remain easy to
read and select. Values from 1.0 through 32.0 are accepted. Labels are
fixed-width: a–z, then aa–zz, and so on.
Motion and scrolling
| Option | Default | Meaning |
|---|---|---|
motion.initial_speed | 60.0 | Initial movement speed in logical pixels per second. |
motion.acceleration | 1400.0 | Controls how quickly movement reaches maximum speed; 0 disables the ramp. |
motion.max_speed | 1800.0 | Movement speed cap. |
motion.tick_hz | 120 | Pointer update frequency while moving; accepted range is 30–1000. |
motion.curve | "ease-in-out" | Velocity ramp: linear, ease-in, ease-out, or ease-in-out. |
scroll.vertical_step | 15.0 | Vertical wheel amount; 15 is one notch. |
scroll.horizontal_step | 15.0 | Horizontal wheel amount; 15 is one notch. |
scroll.target | "pointer" | Target for direct mousr scroll commands: pointer or focused-window. |
CLI mousr scroll DIRECTION --step AMOUNT overrides the configured scroll step.
The Wayland virtual-pointer path sends the requested continuous amount together
with a discrete notch count rounded to the nearest whole notch, with a minimum
of one. The Sway IPC fallback emits only whole notches using that same rounding.
By default, direct scroll commands leave the cursor in place and scroll the
surface under it. Set target = "focused-window" under [scroll] to move the
cursor to the center of the configured seat's focused window content before
scrolling. The cursor stays there afterward; it is not restored. On Sway, the
window is found through IPC. If no usable focused window is available, the
command fails without scrolling at the old pointer location.
This setting does not change scrolling inside grid, mouse, or interactive scroll
modes: those use the selected location or current pointer. A window's center
may land in a different scrollable pane than intended; use grid selection for
precise targeting. Moving the pointer can affect hover state and interacts with
focus_follows_mouse as normal.
Relative mouse movement uses the compositor's global logical coordinate space,
so it crosses outputs according to the layout configured in Sway or wlr-randr.
Fractional motion is preserved, allowing precise movement below one logical
pixel per update.
Bindings
All values are XKB keysym names or single UTF-8 characters.
| Grid option | Default | Grid option | Default |
|---|---|---|---|
left_click | "s" | middle_click | "d" |
right_click | "f" | enter_mouse | "g" |
double_click | "c" | scroll_up | "u" |
scroll_down | "e" | scroll_left | "y" |
scroll_right | "o" | move_only | "space" |
descend | "Return" | back | "BackSpace" |
cancel | "Escape" |
These keys live under [bindings.grid].
| Mouse option | Default | Mouse option | Default |
|---|---|---|---|
left | "h" | down | "j" |
up | "k" | right | "l" |
left_button | "s" | middle_button | "d" |
right_button | "f" | button_lock | "v" |
double_click | "c" | scroll_up | "u" |
scroll_down | "e" | scroll_left | "y" |
scroll_right | "o" | cancel | "Escape" |
These keys live under [bindings.mouse]. Button keys mirror physical state, so
holding one while moving performs drag-and-drop. Cancelling releases all held
buttons. Press c (or the configured double_click key) for an explicit left
double-click; pressing the left button key twice also works. Press
button_lock, then a button key, to lock that button without a chord; press
button_lock again to release it. Mouse bindings must be non-empty and unique.
UI
Colors accept #RGB, #RGBA, #RRGGBB, or #RRGGBBAA. Short digits expand,
so #fff is opaque white and #fff0 is transparent white. The alpha component
controls opacity. Overlay, cell, label, matched-prefix, selection, badge,
border, and target colors are independently configurable.
When magnified refinement is active, Mousr temporarily hides the overlays and
captures a fresh output image on each descent, draws that screenshot inside the
lens, and dims the area outside it
with lens_scrim_opacity. The grid's tile fill is painted over the screenshot;
lens_cell_opacity multiplies the tile fill's own alpha, so lowering it makes
the preview clearer without changing labels or grid lines. If screencopy is not
available or capture fails, refinement continues without the screenshot lens.
| Option | Meaning |
|---|---|
font_path, font_size | Optional TTF/OTF path and label size. An embedded font is the fallback. |
overlay_background, cell_background | Full overlay and cell fill colors. |
lens_scrim_opacity | Opacity used to dim everything outside a magnified refinement lens. |
lens_border, lens_border_width | Magnified refinement lens outline. |
lens_animation_ms | Grid-level transition duration in milliseconds; 0 disables animation. |
lens_cell_opacity | Multiplier applied to cell_background opacity inside the lens. |
grid_border, grid_border_width | Grid line color and width. |
label_background, label_foreground | Normal label colors. |
matched_background, matched_foreground | Colors for the matched label prefix. |
selected_background, selected_border, selected_border_width | Selected-cell styling. |
badge_background, badge_foreground, badge_border, badge_border_width | Mouse/scroll mode badge styling. |
target_ring, target_ring_width, target_ring_radius | Selected pointer-target ring styling. |
show_badge, show_target_ring | Toggle mode feedback elements. |
show_action_hints | Show configured actions after grid selection and in mouse mode. |
Both action tables use the badge background, foreground, and border colors.
Descending into or backing out of a magnified level uses a short ease-out
transition controlled by lens_animation_ms. Keyboard input interrupts the
transition immediately; the renderer also limits the number of animation
frames on very large outputs. Set the duration to 0 to disable it.
If the Wayland keyboard or output disappears during suspend/resume or display reconfiguration, Mousr cancels the active mode, releases held buttons, parks its overlays, and rebinds the keyboard when the selected seat returns.
The example configuration shows all settings with their
default values except grid.refinement_zoom, which is set to 4.0 to demonstrate
magnification; its built-in default is 1.0.
Architecture#
Commands such as mousr grid connect to the daemon over a local IPC socket and exit. The daemon holds the session state and uses two adapters.
App(src/app.rs) owns commands, sessions, rendering, capture policy, animation, and motion.DisplayBackend(src/backend.rs) supplies output geometry, focus, presentation, asynchronous capture, timers, and pointer events. The Wayland adapter implements it.CompositorControl(src/compositor.rs) isolates compositor commands;src/sway.rsimplements it.
The renderer produces packed, premultiplied BGRA frames. Default sessions take keyboard focus through layer-shell; the opt-in focus-preserving path uses a session-scoped input-method v2 grab. An adapter that cannot apply the focus policy must fail and must not take focus.
Logging#
Stderr uses compact DBG, INF, WRN, ERR, and PNC prefixes with UTC timestamps. Logging options apply to the current process, so start the daemon itself with debug logging to see daemon diagnostics:
mousr --log-level debug daemon mousr --log-level debug --log-file ~/.local/state/mousr/logs/debug.json daemon
--log-file also writes JSON-lines diagnostics to the given file.
Building from source#
Building requires a stable Rust toolchain and the libxkbcommon development files.
git clone https://github.com/toxdes/mousr cd mousr cargo build --release cargo install --path . --bin mousr
Debug builds identify as mousr-dev and use a separate IPC socket, so a development daemon can run alongside an installed release. Run ./target/debug/mousr cancel before restarting it.
cargo test --no-default-features tests the shared runtime without the Wayland and Sway adapters. See CONTRIBUTING.md for testing under Sway.