Re: X coordinates displayed interactively.
On 2022-06-19 18:38:50 +0200, Andreas Rönnquist wrote:
> A simple solution would be something like the one described in
>
> https://askubuntu.com/questions/346913/show-realtime-mouse-cursor-coordinates-cursor-mod-overlay-also-copy-to-c
I've added my own, complete solution:
xterm -geometry 9x1+0+0 +sb -sl 0 -T 'Mouse location' -e '
set -e; tput civis; stty quit "^[";
while true; do
eval $(xdotool getmouselocation --shell) && printf "%4d %4d\r" $X $Y;
sleep .05;
done'
(this can be written on one line if need be).
Some explanations:
* The -geometry 9x1+0+0 puts the terminal at the top left, with the
expected size.
* The +sb tells xterm not to display a scrollbar.
* The -sl 0 avoids an unnecessary scrolling buffer.
* The tput civis makes the cursor invisible (it would be annoying).
* The stty quit "^[" allows one to quit with the Esc key instead of
Ctrl-\.
* Concerning the sleep value, I find 0.1 too large; 0.05 seems OK.
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Reply to: