Ubuntu – Won’t rc.local run xinput


I added this command to the rc.local file:

xinput float 12

Then I saved the file. But when I reboot my PC, Ubuntu doesn't execute this command, cause the internal keyboard of my laptop is still working. What should I do?

Best Answer

Most likely the command is being executed.

The xinput float technique given in Is there a way to disable a laptop's internal keyboard? works... but not if you run it from rc.local. xinput requires the X Window System to be running. But it's not running yet at the time rc.local is executed.

Most of the time, the best solution is to have your xinput command run automatically every time you log in graphically. See:

Open Startup Applications (you can search for it in the dash). In the Startup Programs tab of the Startup Applications Preferences window, click the Add button.

screenshot showing how to make a startup entry for an xinput float command
I took this screenshot on a MATE desktop, but if you use Ubuntu's default Unity desktop, or GNOME Shell, it's the same.

Fill in the fields:

  • Put whatever you want for Name. It should probably be something descriptive, like "Disable Internal Keyboard."
  • For Command, put xinput float 12 (assuming 12 is the number of the device you wish to disable, as shown in the output of xinput list).
  • Comment is optional.

Then click Add.

Log out and back in, to check if it works.