UnixForce
UnixForce

Reputation: 23

Bash script does not recognize device id?

I've been working on a script that will run on startup but I am running into a problem. The script is meant to slow mouse acceleration because I use a gaming mouse and it's always too fast.

When I use xinput --list I get this output (out of many other lines):

SteelSeries Sensei Raw Gaming Mouse id=10 [slave pointer (2)]

When I open terminal and run this command, everything runs fine and my sensitivity is changed:

xinput --set-prop 10 "Device Accel Constant Deceleration" 2

However, when I put the above string in a shell.sh with 'eval' in the beginning, it prompts me the following error:

property 'Device' doesn't exist, you need to specify its type and format

What am I doing wrong?

Upvotes: 2

Views: 186

Answers (2)

Jamil Said
Jamil Said

Reputation: 2093

As said on other posts, you don't need to use eval. I would also add something else: you should use the name of the device, rather than the id number, because the id number can change if you add things to your computer (or for other more obscure reasons, too). I would recommend this:

xinput --set-prop "SteelSeries Sensei Raw Gaming Mouse" "Device Accel Constant Deceleration" 2

Upvotes: 1

chepner
chepner

Reputation: 530960

You don't need eval; put the command exactly as you used it from the terminal in your script.

The problem is that eval essentially reparses the string it receives, which results from joining the arguments arguments with whitespace. Your eval command is equivalent to

xinput --set-prop 10 Device Accel Constant Deceleration 2

You could use eval if you quoted the entire string:

eval 'xinput --set-prop 10 "Device Accel Constant Deceleration" 2'

but there is no reason to do so; just use

xinput --set-prop 10 "Device Accel Constant Deceleration" 2

Upvotes: 3

Related Questions