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#

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:

~/.config/sway/config
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.

  1. Type a label. Labels are fixed-width base-26 strings: a to z, then aa to zz. Cells that no longer match are dimmed. grid.unmatched controls this.
  2. Refine. A complete label selects the cell. Return subdivides it. BackSpace erases a character or returns one level.
  3. 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.

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.

text
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:

OptionMeaning
--log-level LEVELerror, warn, info, debug, or trace; default: info.
--log-file PATHAlso 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.

OptionMeaning
--config PATHUse PATH instead of the default configuration file.
--seat NAMEUse 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.

OptionValuesMeaning
--scopefocused, allOverride the configured output scope.
--outputoutput nameTarget one active Wayland output.
--actionaction belowRun an action when a label is selected.
--auto-descend—Descend automatically when another level fits.
--no-auto-descend—Disable automatic descent.
--max-depthu8 integerOverride 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:

ActionResult after selection
chooseWait for a grid-mode action key. This is the default.
moveMove to the cell centre and exit.
mouseMove to the cell centre and enter mouse mode.
left, middle, rightMove, click that button, and exit.
double-clickMove, double-click the left button, and exit.
scrollMove and enter persistent scroll mode.
scroll-up, scroll-downMove and scroll vertically; exit only if grid.exit_on_scroll is enabled.
scroll-left, scroll-rightMove 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:

KeysAction
a–zEnter a label.
s, d, fLeft, middle, or right click.
cDouble-click the left button.
u, e, y, oScroll up, down, left, or right.
gEnter mouse mode.
SpaceMove to the selected cell and exit.
EnterDescend into the selected cell.
BackspaceErase a character or return one level.
EscapeCancel.

mouse

Starts continuous keyboard pointer control.

text
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:

sway
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 keysAction
h, j, k, lMove left, down, up, or right.
s, d, fHold/release left, middle, or right button.
cDouble-click the left button.
v then s, d, or fLock a button; press v again to release it.
u, e, y, oScroll up, down, left, or right.
EscapeRelease 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

text
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

Version output is <name> v<version>(<short-commit>), for example mousr v0.1.1(1a2b3c4d) or mousr-dev v0.1.1(1a2b3c4d).

Default keybindings#

ModeKeys
Grid labelsa to z select cells
Grid actionss d f left/middle/right click · c double-click · u e y o scroll · g mouse mode · Space move
Grid navigationReturn descend · BackSpace back · Escape cancel
Mouse movementh j k l left/down/up/right
Mouse buttonsHold s d f for left/middle/right · c double-clicks left · combine with movement to drag
Button lockv then s d f locks a button · v releases it
Mouse scrollingu e y o up/down/left/right
Mouse exitEscape 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

OptionDefaultMeaning
general.scope"focused"Initial grid scope: focused or all.
general.preserve_focusfalseKeep 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

OptionDefaultMeaning
grid.root_min_tile_width96Minimum logical cell width for the first grid level.
grid.root_min_tile_height54Minimum logical cell height for the first grid level.
grid.min_tile_width16Minimum displayed recursive cell width; magnified source cells may be smaller.
grid.min_tile_height16Minimum displayed recursive cell height; magnified source cells may be smaller.
grid.refinement_zoom1.0Magnification applied to the selected rectangle at each recursive level; 1.0 disables the lens.
grid.max_label_length3Maximum base-26 label length, from 1 through 4.
grid.max_depth4Maximum recursive selection depth.
grid.max_cells4096Hard cell-count and rendering-work limit.
grid.auto_descendfalseDescend immediately after selecting a cell when possible.
grid.exit_on_scrollfalseExit grid mode after a directional scroll action.
grid.unmatched"dim"Render unmatched cells as keep, dim, or hide.
grid.unmatched_opacity0.18Opacity 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

OptionDefaultMeaning
motion.initial_speed60.0Initial movement speed in logical pixels per second.
motion.acceleration1400.0Controls how quickly movement reaches maximum speed; 0 disables the ramp.
motion.max_speed1800.0Movement speed cap.
motion.tick_hz120Pointer 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_step15.0Vertical wheel amount; 15 is one notch.
scroll.horizontal_step15.0Horizontal 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 optionDefaultGrid optionDefault
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 optionDefaultMouse optionDefault
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.

OptionMeaning
font_path, font_sizeOptional TTF/OTF path and label size. An embedded font is the fallback.
overlay_background, cell_backgroundFull overlay and cell fill colors.
lens_scrim_opacityOpacity used to dim everything outside a magnified refinement lens.
lens_border, lens_border_widthMagnified refinement lens outline.
lens_animation_msGrid-level transition duration in milliseconds; 0 disables animation.
lens_cell_opacityMultiplier applied to cell_background opacity inside the lens.
grid_border, grid_border_widthGrid line color and width.
label_background, label_foregroundNormal label colors.
matched_background, matched_foregroundColors for the matched label prefix.
selected_background, selected_border, selected_border_widthSelected-cell styling.
badge_background, badge_foreground, badge_border, badge_border_widthMouse/scroll mode badge styling.
target_ring, target_ring_width, target_ring_radiusSelected pointer-target ring styling.
show_badge, show_target_ringToggle mode feedback elements.
show_action_hintsShow 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.

mousr grid short-lived client IPC socket App runtime sessions · rendering capture policy · motion animation Wayland adapter layer-shell overlays keyboard · virtual pointer screencopy · input-method v2 Sway IPC focused output cross-output warps pointer fallbacks DisplayBackend CompositorControl

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:

shell
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.

shell
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.