Application which will display the current coordinates of the mouse cursor?

I'd like to be able to display the current location of the pointer on the X display. Is there any application which does this?


Solution 1:

There's a package called xdotool that has an application named getmouselocation, available from ubuntu repositories with sudo apt-get install xdotool. Running the command

xdotool getmouselocation

will output

x:1285 y:10 screen:0

Solution 2:

  1. Install xdotool
  2. Open a terminal and paste this:

    while true; do clear; xdotool getmouselocation; sleep 0.1; done
    

Move the cursor over the screen and you will see live coordinates update on terminal.

Solution 3:

xev from the command line shows this. Try the following.

xev

Current coordinates are displayed as root:(<x>,<y>).

Solution 4:

Here's a python script:

#!/usr/bin/env python3
from Xlib import display
import sys

while True:
    c = display.Display().screen().root.query_pointer()._data
    x = c["root_x"]
    y = c["root_y"]

    sys.stdout.write(f'{x:04} {y:04}\r')
    sys.stdout.flush()

Save it to file myscript.py, and launch with python3 myscript.py.