Skip to content

Control the mouse pointer with the keyboard on Wayland.

License

Notifications You must be signed in to change notification settings

moverest/wl-kbptr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wl-kbptr

wl-kbptr — short for Wayland Keyboard Pointer — is a utility to help move the mouse pointer with the keyboard.

demo

It works in two phases: the screen is first in mapped with three letter labels and then the selected area is refined by bisecting it. At any point the cursor can be moved at the location marked by the red marker by pressing Enter or Space. A left, right and middle click can be made by pressing the g, h and b keys respectively.

Note that your compositor needs to support the wlr-layer-shell-unstable-v1 and wlr-virtual-pointer-unstable-v1 protocols.

Installation

Arch Linux

If you are using Arch Linux, you can install the wl-kbptr AUR package.

You can build and install the package with:

curl 'https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=wl-kbptr' -O PKGBUILD
makepkg -si

NixOS

If you are using NixOS, you can install the wl-kbptr package. Nix can also be used to install wl-kbptr on other distributions.

Chimera Linux

If you are using Chimera Linux, you can install the wl-kbptr package which is available in the contrib repository.

apk add chimera-repo-contrib
apk add wl-kbptr

From sources

You can build from sources with:

meson build
meson compile -C build

Then install with:

meson install -C build

Setting the bindings

Sway

mode Mouse {
    bindsym a mode default, exec 'wl-kbptr-sway-active-win; swaymsg mode Mouse'
    bindsym Shift+a mode default, exec 'wl-kbptr; swaymsg mode Mouse'

    # Mouse move
    bindsym h seat seat0 cursor move -15 0
    bindsym j seat seat0 cursor move 0 15
    bindsym k seat seat0 cursor move 0 -15
    bindsym l seat seat0 cursor move 15 0

    # Left button
    bindsym s seat seat0 cursor press button1
    bindsym --release s seat seat0 cursor release button1

    # Middle button
    bindsym d seat seat0 cursor press button2
    bindsym --release d seat seat0 cursor release button2

    # Right button
    bindsym f seat seat0 cursor press button3
    bindsym --release f seat seat0 cursor release button3

    bindsym Escape mode default
}

bindsym $mod+g mode Mouse

Hyprland

# Cursor submap (similar to the Mouse mode in Sway)
submap=cursor

# Jump cursor to a position
bind=,a,exec,hyprctl dispatch submap reset && wl-kbptr && hyprctl dispatch submap cursor

# Cursor movement
binde=,j,exec,wlrctl pointer move 0 10
binde=,k,exec,wlrctl pointer move 0 -10
binde=,l,exec,wlrctl pointer move 10 0
binde=,h,exec,wlrctl pointer move -10 0

# Left button
bind=,s,exec,wlrctl pointer click left
# Middle button
bind=,d,exec,wlrctl pointer click middle
# Right button
bind=,f,exec,wlrctl pointer click right

# Scroll up and down
binde=,e,exec,wlrctl pointer scroll 10 0
binde=,r,exec,wlrctl pointer scroll -10 0

# Scroll left and right
binde=,t,exec,wlrctl pointer scroll 0 -10
binde=,g,exec,wlrctl pointer scroll 0 10

# Exit cursor submap
# If you do not use cursor timeout or cursor:hide_on_key_press, you can delete its respective cals
bind=,escape,exec,hyprctl keyword cursor:inactive_timeout 3; hyprctl keyword cursor:hide_on_key_press true; hyprctl dispatch submap reset 

submap = reset

# Entrypoint
# If you do not use cursor timeout or cursor:hide_on_key_press, you can delete its respective cals
bind=$mainMod,g,exec,hyprctl keyword cursor:inactive_timeout 0; hyprctl keyword cursor:hide_on_key_press false; hyprctl dispatch submap cursor

Configuration

wl-kbptr can be configured with a configuration file. See config.example for an example and run wl-kbptr --help-config for help.

Dependencies

License

GPL-3.0

About

Control the mouse pointer with the keyboard on Wayland.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages