UnixForce UnixForce - 1 year ago 69
Bash Question

Bash script does not recognize device id?

I've 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

What am I doing wrong?

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download