Skip to content

Instantly share code, notes, and snippets.

@sigboe
Forked from mauron85/suspend-modules
Last active April 16, 2024 03:57
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sigboe/2602f9318b8f55ca92c7755a5b70644d to your computer and use it in GitHub Desktop.
Save sigboe/2602f9318b8f55ca92c7755a5b70644d to your computer and use it in GitHub Desktop.
Systemd unload modules on sleep
#!/bin/bash
# Put into /lib/systemd/system-sleep/suspend-modules
# chmod a+x /lib/systemd/system-sleep/suspend-modules
# Unloads kernel modules defined in /etc/suspend-modules.d/*.conf
# and /etc/suspend-modules
# with one module per line
# Too see credits, see git history
# https://gist.github.com/sigboe/2602f9318b8f55ca92c7755a5b70644d/edit
case $1 in
pre)
for mod in $(cat /etc/suspend-modules 2> /dev/null; awk 1 /etc/suspend-modules.d/*.conf 2> /dev/null); do
rmmod $mod
done
;;
post)
for mod in $(cat /etc/suspend-modules 2> /dev/null; awk 1 /etc/suspend-modules.d/*.conf 2> /dev/null); do
modprobe $mod
done
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment