Thursday, July 23, 2015

Touchpad not working after suspend on Debian Jessie

You can try some tricks, like adding

quiet splash i8042.notimeout atkbd.reset

to /etc/default/grub (line GRUB_CMDLINE_LINUX_DEFAULT=)

and then run
sudo update-grup and reboot

Or run
gconftool-2 --set --type boolean /desktop/gnome/peripherals/touchpad/touchpad_enabled true
if your touchpad is simply hardware-disabled.

As for me, nothing mentioned above worked. I use a workaround, that unplugs and plugs in the touchpad again, here what it looks like

rmmod psmouse
modprobe psmouse

I was forced to call this after every awakening, and this was very annoying. I thought about automating all this. Most articles I read tried to use pm-suspend and some custom hooks for it:

sudo vim /etc/pm/sleep.d/0000trackpad
  1 cat /etc/pm/sleep.d/0000trackpad
  2 #!/bin/sh
  3 case "$1" in
  4     suspend|hibernate)
  5          modprobe -r psmouse ;;
  6     resume|thaw)
  7         modprobe psmouse ;;
  8 esac

This worked, but... It turned out that debian does not use pm-suspend when it suspends =(
To suspend and awake with touchpad working I had to sudo pm-suspend manually, so annoying. And again, when debian suspends from low battery or lid closed, it suspends without pm-suspend, so I had to run my annoying script.


Debian uses systemd to manage power, so should I. By the way, when duckduckgoing word "systemd" a lot of controversial and critical posts come up about it being too complex and handling too much responsibility, try it!

systemd provides it's own environment to create hooks, so I created one that finally worked!

sudo vim /etc/systemd/system/touchpad_awakening.service 

Description=Reload mouse after suspend



(mouse is the script that modprobes the psmouse)

then, enable the service by
sudo systemctl enable touchpad_awakening.service 
and start manually to check it by
sudo systemctl start touchpad_awakening.service
check the result
sudo systemctl status touchpad_awakening.service

it reads:
● touchpad_awakening.service - Reload mouse after suspend
   Loaded: loaded (/etc/systemd/system/touchpad_awakening.service; enabled)
   Active: inactive (dead) since Thu 2015-07-23 16:08:20 EEST; 5s ago
  Process: 4285 ExecStart=/home/asalle/bin/mouse (code=exited, status=0/SUCCESS)
 Main PID: 4285 (code=exited, status=0/SUCCESS)

After suspend it worked okay. 
At last!