Left4Code

A Method to Ditch Your Mouse on Linux

--| Posted: 2024-09-24

If you've been hunting for ways to become more efficient at completing your daily tasks by using things like dwm, dmenu, or rofi, vim extensions, etc., you may have adopted the core philosophy that your hands should be on the keyboard at all times. This post is for you to expand upon and use. With that out of the way, the small guide begins!

Prerequisites for Advanced Usage:

sxhkd, xdotool, rofi/dmenu

If I ever get the time, I will make a part two to this post detailing how to extend the usage of the setxkbmap command with a shell script to automatically place your mouse on a tile of the screen based on a map I'll create for it that's easy to remember.

The Ultimate Command:

Content drop! Xorg supports mouse movement using the numpad when you type the command:

setxkbmap -option keypad:pointerkeys

With this, we get basically all the functionality of a mouse on our numpad. Just start it by pressing shift plus the numlock key. The only real pitfalls I can see with this are that the mouse starts moving slowly and there's no real way to replicate what Firefox extensions like Vim Vixen or Vimium do. But if you have no mouse or just refuse to use one, it does the job very well and after not using my mouse for a day I didn't find a task it was unable to complete.

Understanding funny numpad mouse

All of the bindings can be found on the Gentoo Wiki also, setxbmap has a lot of additional functionality like Changing keyboard layouts, key composition, and some other things.

But to boil everything down on this page, all of the keys you need to know are: /, *, - — selects left click, middle click, or right click mode 1-4,6-9 — mouse directional keys 0 — used in combination with left click to basically click and hold or click and drag 5 — click! + — Mouse double click . — release mouse button

If you're on a system where your xinitrc actually works and you don't need to patch dwm with autostart after compiling, then you can literally just put the command in your xinitrc and have this functionality all the time, also it doesn't seem to get rid of the original numpad functionality, so that's an added bonus.

Practicality of using this

It's not, at least in the current state it's in, if there's a way to change the default speed of how fast the cursor goes and change the setting from the cursor being a sort of linear ramp and just have a flat speed or a faster time to reach full speed, then it could be really nice, but that will hopefully be possible with some more research in part 2 (if it ever comes out.)