You are not logged in.

#1 2014-03-22 16:33:35

zubonpants
Member
Registered: 2014-03-19
Posts: 4

Unload and reload a module after wake from s2disk

Hi,

I think I'm close to getting what I need, but I might need some help with proper syntax.
I need to unload and reload a kernel module after waking from suspend2disk.
Basically i'm trying to avoid typing: 'sudo rmmod cyapa && modprobe cyapa' everytime my laptop wakes to re-enable my laptop's touchpad.

I know I need to make a systemd unit depending on the hibernate service. So here are the two units I use. The first is the hibernate service I use to suspend2disk. The second is the systemd unit i made to unload and reload the cyapa module for my touchpad. I can suspend with the hibernate service file no problem. But when I have the resume module in the directory I can't hibernate or do what the script does. Any insight would be great.

hibernate service:

[Unit]
Description=Hibernate
Documentation=man:systemd-suspend.service(8)
DefaultDependencies=no
Requires=sleep.target
After=sleep.target

[Service]
Type=oneshot
ExecStart=/bin/sh -c 's2disk && run-parts --regex .\* -a post /usr/lib/systemd/system-sleep'

moduleloading/resume service:

local-system-resume.service

[Unit]
Description=Local system resume actions
After=hibernate.target

[Service]
Type=oneshot
ExecStart=/usr/sbin/rmmod cyapa && /usr/sbin/modprobe cyapa

[Install]
WantedBy=hibernate.target

Offline

#2 2014-03-22 17:39:55

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: Unload and reload a module after wake from s2disk

Why are you using s2disk and not systemd's hibernation?

systemd on sleep/hibernation/resume/thaw runs scripts in /usr/lib/systemd/system-sleep and your ExecStart partly emulates that - you could put a script there running rmmod & modprobe in case of "post".

Offline

#3 2014-03-23 06:38:28

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: Unload and reload a module after wake from s2disk

You can also use this handy script which basically does the same as described by lucke:

https://aur.archlinux.org/packages/syst … d-modules/

Offline

Board footer

Powered by FluxBB