Register
It is currently Tue Sep 23, 2014 10:21 am

Shell script to find mouse ID and change its pointer speed


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Wed Jun 18, 2014 7:54 am   

Joined: Wed Jun 18, 2014 7:29 am
Posts: 2
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


Top
 Profile  
 PostPosted: Wed Jun 18, 2014 9:31 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 548
hi,

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


Top
 Profile  
 PostPosted: Wed Jun 18, 2014 10:02 am   

Joined: Wed Jun 18, 2014 7:29 am
Posts: 2
Oh, boy! It worked like a charm! :)

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

brunces


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP