10

Kubuntu 11.10 (netbook edition)

My wife's netbook has the following problem: when the lid is closed, it activates the touchpad every now and then - it makes small movements and taps. The notebook is set not to go to sleep while the AC adapter is plugged in, so whenever the lid closes, it keeps doing things on its own.

Especially annoying when pausing a film and going to sleep, as after a while it will tap on the player window and resume the film, scaring the crap out of everyone around.

I didn't find any option to disable the touchpad while the lid is down, but maybe there's some kind of an event I could hook into and disable/re-enable it manually?

3 Answers 3

11

Since nobody could tell me how to do exactly what I wanted, here's the solution I came up with:

Disabling the touchpad/mouse

$ xinput --list
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ FSPPS/2 Sentelic FingerSensingPad         id=12   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Sleep Button                              id=8    [slave  keyboard (3)]
    ↳ Power Button                              id=9    [slave  keyboard (3)]
    ↳ USB2.0 UVC PC Camera                      id=10   [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=11   [slave  keyboard (3)]
    ↳ MSI Laptop hotkeys                        id=13   [slave  keyboard (3)]

As we can see, my touchpad is the one with id=12. To disable it, I need to run:

$ xinput set-int-prop 12 "Device Enabled" 8 0

and to enable it again:

$ xinput set-int-prop 12 "Device Enabled" 8 1

Getting the lid state

First of all, I can get the state of the lid on my system from this file:

$ cat /proc/acpi/button/lid/LID0/state 
state:      open

When I close the lid, the state becomes closed.

Now to get the state as a variable, I can check the exit status of a nifty grep command:

$ grep -q closed /proc/acpi/button/lid/*/state
$ echo $?
1

So to enable or disable the touchpad depending on the lid state, all I need to do is:

$ grep -q closed /proc/acpi/button/lid/*/state
$ xinput set-int-prop 12 "Device Enabled" 8 $?

Hooking the ACPI lid event

To execute the above commands every time the lid closes or opens, I created the file /etc/acpi/local/lid.sh.post with the following content:

export XAUTHORITY=`ls -1 /home/*/.Xauthority | head -n 1`
export DISPLAY=":`ls -1 /tmp/.X11-unix/ | sed -e s/^X//g | head -n 1`"

grep -q closed /proc/acpi/button/lid/*/state
xinput set-int-prop 12 "Device Enabled" 8 $?

XAUHTORITY and DISPLAY need to be set in order to allow root (who runs the acpid process) to access the user's X session.

1
  • Hello, Attila, and thank you for this answer! I spent about an hour before found your explanation about $XAUHTORITY and $DISPLAY. I've created my own scrip that could be interesting for you: askubuntu.com/a/980999/566421
    – pa4080
    Nov 28, 2017 at 12:21
2

What you can do is put your computer to sleep before closing the lid. that way, pressing the power button would resume the sleep, and the lid closed won't affect the touchpad.

Alternativly, you can open your terminal (ctrl+alt+T) and type

sudo rmmod psmouse

It allows a usb mouse, wireless or otherwise, but shuts down the touchpad.

Also, you have the option to install touchpad-indicator, wich provide an easy way to deactivate your touchpad

sudo add-apt-repository ppa:atareao/atareao
sudo apt-get update
sudo apt-get install touchpad-indicator

It will be under Application > Accesory OR, depending on your UI, will be a small "touchpad-like" button next to the volume button

1
  • That wouldn't be good, as there might be tasks that I don't want to stop (e.g. a music player or a download process), but I still want to close the lid.
    – Attila O.
    Dec 30, 2011 at 14:55
0

I would really like such a function aswell, but I have taken the habit from now on to disable the touchpad before closing the lid with the shortcut (Fn + F7 here, depends on make and model of laptop). Sure, this doesn't solve the problem at all, but it's a big start. If you don't have a keybind preset into your laptop, I'm quite sure there's a way to bind one manually.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .