BashScripts.org
http://bashscripts.org/forum/

Shell script to find mouse ID and change its pointer speed
http://bashscripts.org/forum/viewtopic.php?f=16&t=1827
Page 1 of 1

Author:  brunces [ Wed Jun 18, 2014 7:54 am ]
Post subject:  Shell script to find mouse ID and change its pointer speed

Hello, guys. What's up?

I've recently bought a bluetooth mouse and its pointer normal speed is very fast. So, every time I turn on my laptop or log out and log back in again, I have to change its speed. After some searching, I found the following commands on internet:

1) I have to find out my mouse ID, so I use this command...
xinput list

... which gives me this output...
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=13 [slave pointer (2)]
⎜ ↳ Samsung S Action Mouse ET-MP900D id=11 [slave pointer (2)]

2) Now that I know the ID, I use this command...
xinput set-prop 11 "Device Accel Constant Deceleration" 1.75
xinput set-prop 11 "Device Accel Adaptive Deceleration" 1.75

And it's done! It works perfectly!

So I decided to create a bash script to do this automatically every time a logged in. I did it, but then I realized that the ID sometimes changes. For example, sometimes it's 11, sometimes it's 13, so my bash script wouldn't work properly.

So, here I am to ask you, experts, if there is any way to get this ID automatically, maybe using GREP, I don't know. The mouse is always the same, a "Samsung S Action Mouse ET-MP900D". Actually, if you don't mind, please, I'd like you to show me how to do that because, I confess, this "bash thing" is something very new to me. I know the logic, I mean, I know I will have to get that ID value and store it in a variable; then I will use this variable in those commands (xinput set-prop [variable] "Device...), but I admit I don't really know how to do that. So, if you could show me how, I would really appreciate it.

Well, that's it. I hope you can help me. Thanks in advance for your time. :)

brunces

Author:  Watael [ Wed Jun 18, 2014 9:31 am ]
Post subject:  Re: Shell script to find mouse ID and change its pointer spe

hi,

Code:
deviceNum=$(xinput list | grep -oP 'Samsung.*id=\K[0-9]*')

Author:  brunces [ Wed Jun 18, 2014 10:02 am ]
Post subject:  Re: Shell script to find mouse ID and change its pointer spe

Oh, boy! It worked like a charm! :)

Thank you so much for your help, Watael. I really appreciate it. Cheers. :)

brunces

Page 1 of 1 All times are UTC - 6 hours
© 2000, 2002, 2005, 2007 phpBB Group • http://www.phpbb.com