#!/bin/sh
case $1 in
pre)
light-locker-command -l
/bin/sleep 5
;;
post)
#something on resume (e.g I restart brcmfmac driver)
rmmod brcmfmac && modprobe brcmfmac
/bin/sleep 5
;;
esac
P.S:
For it to work you have to have a screensaver running in the background (light-locker in my case)
Also change
light-locker-command -l
to whatever locking command you are using.
Hope this helps someone
]]>/lib/elogind/system-sleep/
then
chmod +x
your script.
]]>This has to happen before you call your suspend/hibernate/resume command and therefore related to acpi/acpid and acpi scripts not pm-utils and its scripts which obviously only run once suspend/resume have been called.
I don't have a laptop myself so I have no personal experience of how to do this.
However there is some discussion (and further links) here that might be able to help:
https://askubuntu.com/questions/517683/ … ect=1&lq=1
Ubuntu 14 was the last sysvinit version of Ubuntu before they went over to the systemd darkside.
]]>Added clarification to the post
]]>In order to get hibernation resume to work you'll need to tell the OS where the swap partition is that you will use to store/restore your resume image on.
Edit /etc/default'grub/ to add or amend the line:
GRUB_CMDLINE_LINUX_DEFAULT="quiet resume=UUID=1e9fb381-0966-401f-b649-7958a6df7307"
to name the actual UUID of your swap partition. Obviously the swap partition will have to be large enough to store your ram image.
Then run (as root/sudo) update-grub to update /boot/grub/grub.cfg and reboot.
]]>Installing the pm-utils package installs both binaries and the scripts that are run when you put your machine to sleep/wake it up again.
As root/sudo you can run pm-suspend, pm-hibernate or pm-suspend-hybrid.
I've added the names of the first two of these to my sudoers file so that I can run them from a power menu button on my cinnamon desktop.
The pm-utils configuration scripts are in /etc/pm/ and /usr/lib/pm-utils.
In the former you will have the /etc/pm/config.d/defaults script that (inter-alia) sets the hibernate mode.
This is mine:
##########################################################
# DO NOT EDIT THE FILE in /usr/lib/pm-utils/ #
# #
# Edit this in /etc/pm/config.d/ instead! #
##########################################################
# Default method to power down the system when hibernating.
# If commented out, the system will use the kernel default as a
# default value.
#
# Check /sys/power/disk for valid values. The default value
# will be surrounded by [square brackets].
HIBERNATE_MODE="platform"
# Whether we need to post the video card when resuming from
# hibernate. You should not normally need to set this.
# In the future pm-utils will get this setting from HAL.
#
# Valid values are "no" and "yes"
# HIBERNATE_RESUME_POST_VIDEO="no"
# The default sleep/wake system to use. Valid values are:
# kernel The built-in kernel suspend/resume support.
# Use this if nothing else is supported on your system.
# uswsusp If your system has support for the userspace
# suspend programs (s2ram/s2disk/s2both), then use this.
# tuxonice If your system has support for tuxonice, use this.
#
# The system defaults to "kernel" if this is commented out.
SLEEP_MODULE="kernel"
# These variables will be handled specially when we load files in
# /etc/pm/config.d.
# Multiple declarations of these environment variables will result in
# their contents being concatenated instead of being overwritten.
# If you need to unload any modules to suspend/resume, add them here.
SUSPEND_MODULES="ath9k ath9k_common ath9k_hw ath"
# If you want to keep hooks from running, add their names here.
# HOOK_BLACKLIST=""
# If you want to unconditionally add parameters to the commandline,
# add them here.
# ADD_PARAMETERS=""
# If you want to ignore commandline parameters, add them here.
# DROP_PARAMETERS=""
# If you need to synchronize the system clock across a suspend/resume or
# hibernate/thaw cycle, set this variable.
# NEED_CLOCK_SYNC="true"
My atheros network card refuses to go to sleep so I unload the relevant modules and reload then on waking, hence the SUSPEND_MODULES= line.
I aso have supplementary scripts:
etc/pm/sleep.d/10_unattended-upgrades-hibernate that stops hibernation until unattended upgrades has finished.
and
etc/pm/sleep.d/password-protect-waking that calls a locked screensaver on waking.
In the latter you will find the default scripts that are run when you put your computer to sleep and are then run in reverse when you wake it up. You can also add your own.
I have an additional script /usr/lib/pm-utils/sleep.d/95anacron that start and stops anacron when I sleep the computer. The purpose of this is to defer scripts run by anacron until the computer is awake (regular cron scripts simply don't run if the computer is asleep).
#!/bin/sh
# This script makes anacron jobs stop/start when a workstation
# enters/exits a suspended/hibernated state.
#
case $1 in
resume|thaw)
/usr/sbin/invoke-rc.d anacron start >/dev/null
;;
suspend|hibernate)
/usr/sbin/invoke-rc.d anacron stop >/dev/null
;;
esac
and /usr/lib/pm-utils/sleep.d/wpa-supplicant that notifies wpa-supplicant of pm actions.
#!/bin/sh
# /etc/pm/sleep.d/60_wpa_supplicant
# Action script to notify wpa_supplicant of pm-action events.
PATH=/sbin:/usr/sbin:/bin:/usr/bin
WPACLI=wpa_cli
case "$1" in
suspend|hibernate)
$WPACLI suspend
;;
resume|thaw)
$WPACLI resume
;;
esac
exit 0