Re: which program can show X/Y position of mouse pointer

2022-05-12 Thread Michael Lange
Hi,

On Wed, 11 May 2022 22:34:00 -0400
lou  wrote:

> 
> Thank Michael Lange!
> 
> it's what i need, and it works fine in twm

I am glad if I could help.

Btw, I noticed there is a small bug in the script, there should be an
additional line towards the script's end, so that the end of the script
looks like:

root.bind('<1>', quit)
for sig in (2, 3, 6, 15):
signal(sig, quit)
root.wm_protocol('WM_DELETE_WINDOW', quit) # I forgot this the other day
root.update_idletasks()
start()
root.deiconify()
root.mainloop()
root.destroy()


There shouldn't happen anything nasty without this "WM-protocol" handler,
however when the window is removed by the window manager, without this
line some ugly "crash message" might show up.

> 
> no wonder python is so popular these days

I guess this could be done with even fewer lines of code when written in
Tcl/Tk, I am just more familiar with Python ;)

> 
> PS: why isn't there some existing application that can do this job? is 
> my need too special?
> 

Actually there is at least one:

https://sourceforge.net/projects/mouseposition/

It works here, looks like it just didn't make it into debian.

Have a nice day,

Michael


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

No one wants war.
-- Kirk, "Errand of Mercy", stardate 3201.7



Re: which program can show X/Y position of mouse pointer

2022-05-11 Thread lou



Thank Michael Lange!

it's what i need, and it works fine in twm

no wonder python is so popular these days

PS: why isn't there some existing application that can do this job? is 
my need too special?




Re: which program can show X/Y position of mouse pointer

2022-05-11 Thread Michael Lange
On Mon, 9 May 2022 07:09:57 -0400
Dan Ritter  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:    Y:',
  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



Re: which program can show X/Y position of mouse pointer

2022-05-09 Thread David Wright
On Mon 09 May 2022 at 19:20:25 (-0400), lou wrote:
> 
> On 5/9/22 9:21 AM, Dan Ritter wrote:
> > No, I've never used twm. fvwm, sawmill/sawfish, and xfwm can all
> > do that. Probably most others.
> > 
> 
> Thanks! i have success with icewm, not with fvwm
> 
> xeyes knows mouse movement, it's too bad it doesn't show X/Y coordinates

It works just fine in fvwm. I ran this script in an xterm:

while /bin/true
do
printf '%s ' "$(date +%H:%M:%S)" >> /tmp/mousey-pos
xdotool getmouselocation >> /tmp/mousey-pos
sleep 1
done

I ran this command in another xterm:

$ tail -f /tmp/mousey-pos

I then moved the mouse around the corners of the screen, and then
the corners of the xterm window on the screen. I shifted to another
viewport¹ and repeated (screen, then xterm). Then I switched back
to the original viewport to interrupt the script. The mousey-pos
output is attached.

The coordinates are always for the screen that you are staring at,
not the entire virtual desktop. When you move viewports, the window
numbers naturally all change (except for the clocks/pager/xconsole),
but the X/Y values don't.

There's no need to keep any xterm in view while it's running, if
you're recording the output in a file.

If it really doesn't work for you, there may be some dependency on
the way you start fvwm in .xsession which affects the parent-child
relationships, but that's just a guess.

I also tested using it from a bound keystroke, borrowing the
contortionist's keystroke for re-execing my xinput configuration,
Shift-Ctrl-Alt-/, thus:

#Keyslash   A   CMS Exec exec xinput-xsession quiet
Key slash   A   CMS Exec exec xdotool getmouselocation

$ tail -f .xsession-fvwm-0-log

confirmed that this works too:

[fvwm][Echo]: Reading /home/david/.fvwm/main-menu-pre.hook Last edited 2003 
July 21
[fvwm][Echo]: Reading /home/david/.fvwm/post.hook Last edited 2022-04-02
[fvwm][Echo]: Reading /home/david/.fvwm/last-post.hook-axis-0 Last edited 
2020-04-04
[fvwm][Echo]: Reading /home/david/.fvwm/kbd-base.hook Last edited 2021-11-27
[fvwm][Echo]: Reading /home/david/.fvwm/kbd-axis.hook Last edited 2021-06-18
x:740 y:461 screen:0 window:16777248
x:118 y:83 screen:0 window:16777248
x:1385 y:739 screen:0 window:65011750

I must bind it to a better key. It's a much more controllable
output than xev, John, but I can see virtues in both.

¹ viewport: I have a desktop that's five times wider and four times
higher than the screen, and I switch between these twenty viewports
with clicks in the pager window, or with WindowsKey-arrows or with
Ctrl-Alt-arrows.

A few of the window numbers: root is 1707, …561 and …409 are
swissclocks for two timezones, …761 is the pager, …750 the xconsole,
and all of these are the same in every viewport. …248 is where I ran
the program, started and finished (obviously), and drew the (2nd)
outline round. …400 is an identical xterm on the viewport "next door"
for the 4th outline to go round.

Cheers,
David.
20:26:48 x:787 y:466 screen:0 window:16777248
20:26:49 x:772 y:456 screen:0 window:16777248
20:26:50 x:87 y:110 screen:0 window:16777248
20:26:51 x:13 y:42 screen:0 window:16777248
20:26:52 x:29 y:46 screen:0 window:16777248
20:26:53 x:689 y:78 screen:0 window:16777248
20:26:54 x:1239 y:44 screen:0 window:1707
20:26:55 x:1563 y:28 screen:0 window:62914561
20:26:56 x:1573 y:33 screen:0 window:62914561
20:26:57 x:1569 y:114 screen:0 window:60817409
20:26:58 x:1581 y:478 screen:0 window:1707
20:26:59 x:1573 y:759 screen:0 window:10485761
20:27:00 x:1551 y:820 screen:0 window:10485761
20:27:01 x:1548 y:819 screen:0 window:10485761
20:27:02 x:1249 y:825 screen:0 window:65011750
20:27:03 x:463 y:853 screen:0 window:1707
20:27:04 x:93 y:881 screen:0 window:1707
20:27:05 x:42 y:872 screen:0 window:1707
20:27:06 x:49 y:786 screen:0 window:16777248
20:27:07 x:31 y:208 screen:0 window:16777248
20:27:08 x:26 y:38 screen:0 window:16777248
20:27:09 x:383 y:52 screen:0 window:16777248
20:27:10 x:1023 y:20 screen:0 window:16777248
20:27:11 x:1075 y:34 screen:0 window:16777248
20:27:12 x:1165 y:748 screen:0 window:65011750
20:27:13 x:1093 y:775 screen:0 window:16777248
20:27:14 x:720 y:779 screen:0 window:16777248
20:27:15 x:58 y:740 screen:0 window:16777248
20:27:16 x:37 y:750 screen:0 window:16777248
20:27:17 x:62 y:751 screen:0 window:16777248
20:27:18 x:62 y:751 screen:0 window:18874400
20:27:19 x:62 y:751 screen:0 window:18874400
20:27:20 x:54 y:741 screen:0 window:18874400
20:27:21 x:28 y:430 screen:0 window:18874400
20:27:22 x:38 y:84 screen:0 window:18874400
20:27:23 x:38 y:85 screen:0 window:18874400
20:27:24 x:488 y:53 screen:0 window:18874400
20:27:25 x:1336 y:38 screen:0 window:1707
20:27:26 x:1563 y:33 screen:0 window:62914561
20:27:27 x:1568 y:208 screen:0 window:1707
20:27:28 x:1566 y:727 screen:0 window:65011750
20:27:29 x:1556 y:825 screen:0 window:10485761
20:27:30 x:1288 y:834 screen:0 window:65011750
20:27:31 x:667 y:829 screen:0 window:1707
20:27:32 x:120 y:843 

Re: which program can show X/Y position of mouse pointer

2022-05-09 Thread John Hasler
xev -root
-- 
John Hasler 
j...@sugarbit.com
Elmwood, WI USA



Re: which program can show X/Y position of mouse pointer

2022-05-09 Thread lou



On 5/9/22 9:21 AM, Dan Ritter wrote:

No, I've never used twm. fvwm, sawmill/sawfish, and xfwm can all
do that. Probably most others.

-dsr-



Thanks! i have success with icewm, not with fvwm

xeyes knows mouse movement, it's too bad it doesn't show X/Y coordinates




Re: which program can show X/Y position of mouse pointer

2022-05-09 Thread Dan Ritter
lou wrote: 
> 
> On 5/9/22 7:09 AM, Dan Ritter wrote:
> > xdotool getmouselocation
> 
> 
> Thanks!
> 
> are you sure that xterm can be made always-on-top in twm?

No, I've never used twm. fvwm, sawmill/sawfish, and xfwm can all
do that. Probably most others.

-dsr-



Re: which program can show X/Y position of mouse pointer

2022-05-09 Thread lou



On 5/9/22 7:09 AM, Dan Ritter wrote:

xdotool getmouselocation



Thanks!

are you sure that xterm can be made always-on-top in twm?



Re: which program can show X/Y position of mouse pointer

2022-05-09 Thread Dan Ritter
lou wrote: 
> i use twm for bullseye
> 
> i want to record screen with ffmpeg, it allows me to select some region of
> screen
> 
> i need a program that can display X/Y coordinates of mouse pointer as i move
> mouse

xdotool getmouselocation does it once.

You may wish to run it via watch in a tiny xterm and make that
xterm always-on-top.

-dsr-



which program can show X/Y position of mouse pointer

2022-05-09 Thread lou

i use twm for bullseye

i want to record screen with ffmpeg, it allows me to select some region 
of screen


i need a program that can display X/Y coordinates of mouse pointer as i 
move mouse