Skip to content

Instantly share code, notes, and snippets.

@purarue
Last active October 22, 2025 05:55
Show Gist options
  • Select an option

  • Save purarue/ea40b869798d8b65147ad8ad47eb5c79 to your computer and use it in GitHub Desktop.

Select an option

Save purarue/ea40b869798d8b65147ad8ad47eb5c79 to your computer and use it in GitHub Desktop.
example sway [wayland] configuration for controlling your mouse with your keyboard, using wlrctl and wl-kbptr. keynav-inspired
mode "mouse" {
# Cursor movement
bindsym j exec wlrctl pointer move 0 10;
bindsym k exec wlrctl pointer move 0 -10;
bindsym l exec wlrctl pointer move 10 0;
bindsym h exec wlrctl pointer move -10 0;
bindsym Shift+j exec wlrctl pointer move 0 50;
bindsym Shift+k exec wlrctl pointer move 0 -50;
bindsym Shift+l exec wlrctl pointer move 50 0;
bindsym Shift+h exec wlrctl pointer move -50 0;
bindsym Mod1+j exec wlrctl pointer move 0 2;
bindsym Mod1+k exec wlrctl pointer move 0 -2;
bindsym Mod1+l exec wlrctl pointer move 2 0;
bindsym Mod1+h exec wlrctl pointer move -2 0;
# Click and exit mouse mode
bindsym space exec wlrctl pointer click left; mode "default";
bindsym s exec wlrctl pointer click left; mode "default";
bindsym d exec wlrctl pointer click middle; mode "default";
bindsym f exec wlrctl pointer click right; mode "default";
# Click without exiting mouse mode
bindsym Shift+s exec wlrctl pointer click left;
bindsym Shift+d exec wlrctl pointer click middle;
bindsym Shift+f exec wlrctl pointer click right;
bindsym 1 exec wlrctl pointer click left;
bindsym 2 exec wlrctl pointer click middle;
bindsym 3 exec wlrctl pointer click right;
# Restart wl-kbptr and re-enter mouse mode
bindsym semicolon mode "default"; exec 'wl-kbptr; swaymsg mode "mouse"';
bindsym $mod+semicolon mode "default"; exec 'wl-kbptr; swaymsg mode "mouse"';
# Scroll up and down (if supported)
bindsym e exec wlrctl pointer scroll 10 0;
bindsym r exec wlrctl pointer scroll -10 0;
bindsym t exec wlrctl pointer scroll 0 -10;
bindsym g exec wlrctl pointer scroll 0 10;
bindsym Escape mode "default";
bindsym Return mode "default";
}
bindsym $mod+comma mode "mouse"
bindsym $mod+semicolon exec 'wl-kbptr; swaymsg mode "mouse"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment