Score:1

How to lock mouse movement using xdotool

pm flag

How can I achieve locking my mouse movement on the spot rather than moving to some defined X and Y coordinates? on the spot means if my mouse is in the middle, with just a keybind it'll lock it there rather than moving to the top right or left of the screen.

Score:0
it flag

It's unclear to me the goal of such a script, but you could look up the current position, and keep setting the cursor position to that position.

You'll probably want a more reliable way of killing it, vs Ctrl+C. Think carefully about that before running the following:

eval $(xdotool getmouselocation --shell)
while true
do
  xdotool mousemove $X $Y
  sleep 0.1
done

xdotool getmouselocation --shell provides output like this:

$ xdotool getmouselocation --shell
X=420
Y=69
SCREEN=0
WINDOW=1

When you eval $(xdotool getmouselocation --shell), $X and $Y variables are set.

AzurBarnitzke avatar
pm flag
I am currently using xbindings and within that using xdotool, I'm thinking of assigning my button 9 (extra side mouse buttons) to lock the mouse movement and button 8 to disable it, any idea how to implement said changes...?
it flag
Create this as a script with executable flag (`chmod +x /usr/bin/mouselock`). Execute that with a binding. Then, execute `killall mouselock` or similar with another button. I use `xdotool` to reset my SNES and live splits at the same time hehehe.
AzurBarnitzke avatar
pm flag
Thanks a lot! Will try this out
AzurBarnitzke avatar
pm flag
Hello just tried this out, just wanted to know when I execute the script it locks it in place but it keeps flickering and returning back to the position where I left, is there any way to fix this up without my cursor flickering?
it flag
You could remove/decrease the timeout, which may reduce flickering, if you haven't already. Otherwise, I'm not too sure. Potentially, only move it if you detect a change in X or Y. If you can't figure it out, feel free to ask and create a new question, vs comments.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.