Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ubuntu 16.04 systemd unload modules on sleep
#!/bin/bash
# Put into /lib/systemd/system-sleep/suspend-modules
# chmod a+x /lib/systemd/system-sleep/suspend-modules
# Create /etc/suspend-modules.conf
# with one module per line
# credits to:
# https://bbs.archlinux.org/viewtopic.php?pid=1540125#p1540125
# More info:
# https://ubuntuforums.org/showthread.php?t=2314905&p=13555828#post13555828
case $1 in
pre)
for mod in $(</etc/suspend-modules.conf); do
rmmod $mod
done
;;
post)
for mod in $(</etc/suspend-modules.conf); do
modprobe $mod
done
;;
esac
@sigboe

This comment has been minimized.

Copy link

sigboe commented Dec 6, 2017

If you use

$(awk 1 /etc/suspend-modules/*.conf)

Then you can do this for all .conf files in /etc/suspend-modules/ which seams to be a more modern best practice way to do settings now.

@xxJohnnyRagexx

This comment has been minimized.

Copy link

xxJohnnyRagexx commented Jul 30, 2019

instead of rmmod, I would use modprobe -r

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.