trents_blog/docs/posts/linux-move-cursor-with-keyb...

1.2 KiB

title date draft tags authors
Linux Move Cursor With Keyboard 2020-06-21T22:01:35-07:00 false
X11
xdotool
cursor
keyboard
keyboard shortcuts
trent

date: 2020-06-21T22:01:35-07:00

Introduction

Linux just makes everything so easy. On a laptop it can be tricky to place your mouse cursor on exactly the correct pixel, using the touchpad. This became apparent to myself while using GIMP to create some png button files for a little tkinter project, but there must be other use-cases as well.

xdo commands for moving the cursor

  • move the cursor one pixel left:
xdotool mousemove_relative -- -1 0
  • move the cursor one pixel right:
xdotool mousemove_relative -- 1 0
  • move the cursor one pixel up:
xdotool mousemove_relative -- 0 -1
  • move the cursor one pixel down:
xdotool mousemove_relative -- 0 1

map keyboard shortcuts

Now, in your keyboard settings, map the above commands to new custom shortcuts. For instance, I find the

++ctrl+super+arrow-up++

++ctrl+super+arrow-down++

++ctrl+super+arrow-left++

++ctrl+super+arrow-right++

combinations to be convenient in the Mate Desktop. Enjoy!