This is probably insanely simple but I'm sort of new to this and have no idea what I'm doing. Very simply, I have MouseON.sh that when ran, I want it to open a terminal, run a command, then close the terminal it opened. (yes I know that seems redundant but for my purposes this is what I need). I've googled and looked around this site but can't really find something I can understand due to noobery.

I have:

gnome terminal -x sh -c xinput set-prop 10 "Device Enabled" 0

Which opens and closes the terminal nicely, but doesn't actually run 'xinput set-prop 10 "Device Enabled" 0'


Also, yes I'm aware it's called "MouseON" and setting it to 0 would turn the mouse off, I have it set to that for testing purposes.

I'm also aware there are other ways to turn the mouse on and off but again for my purposes this is what I need.

Thanks in advance.

  • 1
    Quote the argument to -c? gnome terminal -x sh -c 'xinput set-prop 10 "Device Enabled" 0' – kos Jan 25 '16 at 15:09
  • Bah! You're 100% right. Works perfectly now. THANK YOU. – TechnoWolf Jan 25 '16 at 15:10
  • Is there any particular reason why you need to open gnome-terminal for that ? – Sergiy Kolodyazhnyy Jan 25 '16 at 15:27
  • @Serg Please refer to noobery. I'm fairly new to linux and am not a programmer. I don't doubt there's a more efficient way to accomplish this. – TechnoWolf Jan 26 '16 at 16:21

From man gnome-terminal:

       -x, --execute
                 Execute the remainder of the command line inside the  termi‐

When sh -c xinput set-prop 10 "Device Enabled" 0 is evaluated in order to be executed, sh is interpreted as the executable to be run, and the arguments to sh are splitted on spaces; so xinput is intepreted as the argument to sh's -c option and set-prop, 10, Device Enabled and 0 are interpreted as options / arguments to sh, and not as options / arguments to xinput.

The solution is quoting the xinput command using single / double quotes to prevent the command from being splitted on spaces and to make it be interpreted by sh as a whole argument to the -c option:

gnome terminal -x sh -c 'xinput set-prop 10 "Device Enabled" 0'


gnome terminal -x sh -c "xinput set-prop 10 \"Device Enabled\" 0"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.