1
0
Fork 0
mirror of https://github.com/NixOS/nixos-hardware synced 2024-11-26 21:09:42 +01:00

inspiron-5515: fix race for fix-touchpad.sh

On rare occasions, the module would be removed before suspend and the touchpad would be
disabled on boot.
This commit is contained in:
Guillaume Girol 2022-03-05 12:00:00 +00:00
parent a7bca8d0d8
commit fed22c2d60
2 changed files with 11 additions and 5 deletions

View file

@ -12,13 +12,18 @@
# hack around it by unloading and reloading module i2c_hid
systemd.services.fix-touchpad = {
path = [ pkgs.kmod ];
serviceConfig.ExecStart = "${./fix_touchpad.sh}";
serviceConfig.ExecStart = ''${pkgs.systemd}/bin/systemd-inhibit --what=sleep --why="fixing touchpad must finish before sleep" --mode=delay ${./fix_touchpad.sh}'';
serviceConfig.Type = "oneshot";
description = "reload touchpad driver";
# must run at boot (and not too early), and after suspend
wantedBy = [ "display-manager.service" "sleep.target" ];
after = [ "sleep.target" ];
wantedBy = [ "display-manager.service" "post-resume.target" ];
# prevent running before suspend
after = [ "post-resume.target" ];
};
# so that post-resume.service exists
powerManagement.enable = true;
# fix suspend
# https://bbs.archlinux.org/viewtopic.php?id=266108 says linux >= 5.12 required

View file

@ -11,10 +11,11 @@ unload () {
wait_unload() {
while sleep 1; do
case "$(unload "$1")" in
output="$(unload "$1")"
case "$output" in
*is\ in\ use*) :;;
*ok*) return 0;;
*) echo giving up; return 1;
*) echo "modprobe said: $output"; echo giving up; return 1;
esac
done
}