0

I have problems with a touchpad on Lenovo X1 Gen 5th. Each time I unlock my screen session the touchpad is not functioning 100%, namely finger gestures for scrolling are messed up.

I have to run the following command in order to fix it:

sudo rmmod psmouse; sudo modprobe psmouse

My question is: how can I automate that command to be executed each time I unlock the screen?

I have tried scripts in /etc/pm/sleep.d but with no luck.

  • Why don't you try first blacklisting that module? Sometimes your touchpad works fine afterwards. You do it adding blacklist psmouse to /etc/modprobe.d/blacklist.conf – Maccer Mar 19 at 11:18
  • Why would I do it? I guess I need it for my touchpad to work, do I ? – eMarcel Mar 19 at 12:09
  • If I'm not mistaken your problem is that your touchpad doesn't work after suspend right? According to this it's a possible solution for the cases that your touchpad can work with another module. – Maccer Mar 19 at 13:18
  • nah, my touchpad is working but not 100%, scrolling has lags for example. Once I reload psmouse module all is working fine. but how can I automate it to be executed every time I unlock my screen? – eMarcel Mar 19 at 15:21
  • 1
    Check this guide – Maccer Mar 19 at 20:57
1

Looks like we have to answer our questions ourselves to close it:)

If you want to do something before you suspend, like unload a module or run some script, it’s quite easy with systemd. Similarly, you can easily do something when the system resumes (like reload the module).

The details are in the systemd-suspend man page: man systemd-suspend.service

Simply put an executable script of any name under /usr/lib/systemd/system-sleep/ that checks whether the first argument is pre (for before the system suspends) or post (after the system wakes from suspend).

If it is pre, then do the thing you want to before suspend, if it’s post then do the thing you want to do after resume. Simple!

Here’s a useless example:
#!/bin/sh if [ "${1}" == "pre" ]; then # Do the thing you want before suspend here, e.g.: echo "we are suspending at $(date)..." > /tmp/systemd_suspend_test elif [ "${1}" == "post" ]; then # Do the thing you want after resume here, e.g.: echo "...and we are back from $(date)" >> /tmp/systemd_suspend_test fi

So, I implemented this solution from here https://blog.christophersmart.com/2016/05/11/running-scripts-before-and-after-suspend-with-systemd/
That would ensure that after sleep and resume psmodule will get reloaded. This should do.

  • Tried this as well but with no luck. I fixed all my problems with touchpad and killing gala process each time I disconnected remote Monitor by Installing Linux Mint MATE. Thanks! And have fun with eOS. – eMarcel Apr 17 at 14:26

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.