diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/pm-action.in | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/pm-action.in b/src/pm-action.in index 3fe476b..f76f9ae 100644 --- a/src/pm-action.in +++ b/src/pm-action.in @@ -90,4 +90,21 @@ esac export PM_CMDLINE="$@" -pm_main "${ACTION}" "${REVERSE}" +"check_$ACTION" || { echo "System does not support $ACTION sleep."; exit 1; } +take_suspend_lock || exit 1 + +# make sure we release the lock no matter how we exit +trap remove_suspend_lock 0 +init_logfile "${PM_LOGFILE}" + +# Make sure we are not inhibited before we start. +rm -f "${INHIBIT}" + +# run the sleep hooks +run_hooks sleep "$ACTION" + +# Sleep only if we know how and if a hook did not inhibit us. +command_exists "do_$ACTION" && [ ! -e "$INHIBIT" ] && { sync; "do_$ACTION"; } + +# run the sleep hooks in reverse with the wakeup action +run_hooks sleep "$REVERSE" reverse |