PINE64
A hint to help with suspend-related issues - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: Pinebook Pro (https://forum.pine64.org/forumdisplay.php?fid=111)
+--- Forum: General Discussion on Pinebook Pro (https://forum.pine64.org/forumdisplay.php?fid=112)
+--- Thread: A hint to help with suspend-related issues (/showthread.php?tid=8241)



A hint to help with suspend-related issues - diodelass - 11-07-2019

I'm posting this here because I just fixed an irritating issue on my Pinebook Pro and want others to be able to do the same if/when it affects them.

If you've put your Pinebook Pro to sleep and returned to it later, you may have noticed that there are sometimes things broken when it wakes back up. On mine, the keyboard layout modifications I've set using xmodmap (converting caps lock to a second escape, and the |\ key right beside left shift to be an additional left shift, since I'm used to the wider key provided on ANSI keyboards) all get reset back to defaults, and my trackpad stops responding to taps. Both of these were cramping my style enough that was just electing not to use suspend at all.

The solution to these problems is just to run two commands:
Code:
xinput set-prop "HAILUCK CO.,LTD USB KEYBOARD Touchpad" "libinput Tapping Enabled" 1
to enable touchpad taps, and
Code:
xmodmap ~/.Xmodmap
to set my keymap modifications in X.

However, in order to make these happen automatically, we need a way to run commands - which, unfortunately, have to happen within the domain of X - right after the computer resumes from sleep mode. This is a bit more complicated than it should be, but don't worry, I figured that out too.

Step 1: as root, open a new text file in your favorite editor at /etc/systemd/system/resume@.service, and put in these lines:
Code:
[Unit]
Description=User suspend actions
After=suspend.target

[Service]
User=%I
Type=forking
Environment=DISPLAY=:0
ExecStart=/home/%I/.resume.sh

[Install]
WantedBy=suspend.target

Next, run these commands, also as root:
Code:
systemctl daemon-reload
systemctl enable resume@diodelass
(with your name instead of mine after the @, of course!)

Step 2: create the file .resume.sh in your home directory, and mark it executable (chmod +x .resume.sh).
My .resume.sh looks like this now:
Code:
#!/bin/bash

# hold for five seconds to allow the keyboard and touchpad to renumerate
sleep 5

xinput set-prop "HAILUCK CO.,LTD USB KEYBOARD Touchpad" "libinput Tapping Enabled" 1
xmodmap ~/.Xmodmap

Your commands can, of course, be whatever you need. I don't know what other problems with suspending there are on the Pinebook Pro yet, but this little bit of plumbing gives you what you need to put your fixes into action as soon as you know what they are; once you've found a command to fix the resume-related problem, you can simply drop it into .resume.sh and it will be run every time your machine wakes up.

Best of luck to everyone in getting your new system tweaked to perfection!