On Mon, 9 May 2022 07:09:57 -0400
Dan Ritter <d...@randomstring.org> wrote:

(...)
> xdotool getmouselocation does it once.
> 
> You may wish to run it via watch in a tiny xterm and make that
> xterm always-on-top.

just for fun I wrote a little Python/Tk script that does what I believe
the OP wants (requires python3-tk):

#############################################################

#!/usr/bin/python3
# -*- coding: utf-8 -*-
'''Shows a tooltip-like window that displays the
x- and y-positions of the mouse pointer on the screen.
Left-click into this window to quit the program.'''

# coordinates of upper left window corner, edit to fit your needs:
WINDOW_X = 0
WINDOW_Y = 0

from tkinter import *
from signal import signal

root = Tk()
root.withdraw()
l = Label(root, text='Mouse position:\nX: 9999   Y:9999',
          width=18, relief='solid', bd=2)
l.pack()
l.is_running = 0
root.wm_overrideredirect(1)
root.wm_geometry('+%d+%d' %(WINDOW_X, WINDOW_Y))

def show_mouse_pos():
    x, y = l.winfo_pointerxy()
    l.configure(text='Mouse position:\nX: %d   Y: %d' % (x, y))
    if l.is_running:
        l.after(100, show_mouse_pos)

def start():
    l.is_running = 1
    l.after(100, show_mouse_pos)

def quit(*args):
    l.is_running = 0
    l.after(200, root.quit)

root.bind('<1>', quit)
for sig in (2, 3, 6, 15):
    signal(sig, quit)
root.update_idletasks()
start()
root.deiconify()
root.mainloop()
root.destroy()

#####################################################

Have a nice day,

Michael

.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

Killing is wrong.
                -- Losira, "That Which Survives", stardate unknown

Reply via email to