UnixForce UnixForce - 10 days ago 5
Bash Question

Bash scirpt does not recognize device id?

I've been trying to write a script that will run upon startup but I am running into a problem here. I want to write a script that will 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:

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


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


What am I doing wrong?

Answer

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
Comments