How to add a modprobe reset in config?

I have a strange laptop where the trackpad just doesn’t work when it first boots up. But I’ve found that if I run these 2 commands to “reset it”, it then works fine.

I’ve tried a couple kernel params, and then a power resume setting, but neither worked. Every reboot, I have to run these commands.

sudo rmmod i2c_hid_acpi
sudo modprobe i2c_hid_acpi

Is there a good way to just have this as part of the config? Thanks!

The simplest way is probably to make a systemd oneshot service.

Thanks for this! I did some googling and feel like i’m half way there, but it’s still not working automatically. Like when the computer boots up, I still have to type “sudo systemctl start restart-trackpad” and then it works. What am I missing?

this is my config:

systemd.services.restart-trackpad= {
    serviceConfig.Type = "oneshot";
    path = with pkgs; [ bash ];
    script = ''
      bash /home/mkelly/Projects/nix/reset_mouse.sh
    '';
  };

and the script is simply:

/run/current-system/sw/bin/rmmod i2c_hid_acpi
/run/current-system/sw/bin/modprobe i2c_hid_acpi

You’ll need to set it to be WantedBy a target in order to get it into the dependency ordering.

1 Like

Ahhh perfect! thank you!! I did a little trial and error, and THIS finally seems to work.

# Fix for trackpad
  #     test: journalctl -xeu restart-trackpad.service
  systemd.services.restart-trackpad= {
    serviceConfig.Type = "oneshot";
    wantedBy = [ "wpa_supplicant.service" ];
    after = [ "wpa_supplicant.service" ];
    path = with pkgs; [ bash ];
    script = ''
      bash /home/mkelly/Projects/nix/reset_mouse.sh
    '';
  };
1 Like