diff options
author | Victor Lowther <victor.lowther@gmail.com> | 2008-09-17 21:41:26 -0500 |
---|---|---|
committer | Victor Lowther <victor.lowther@gmail.com> | 2008-09-17 21:41:26 -0500 |
commit | 04d25924f782d96ef55f164aea55e3d227a8a3ec (patch) | |
tree | 9c7c88d4e8a74c75ce50119979ed925ab9ba55e5 /pm/module.d/tuxonice | |
parent | 38a9d169b831aa1528a47060612cba3dd5ff3514 (diff) |
Move the check_ functions to pm-functions.
Also conditionalize the do_ functions in the sleep modules. Now, we only
declare the actual do_ functions if the system can in fact sleep using
the requested method.
Diffstat (limited to 'pm/module.d/tuxonice')
-rwxr-xr-x | pm/module.d/tuxonice | 57 |
1 files changed, 21 insertions, 36 deletions
diff --git a/pm/module.d/tuxonice b/pm/module.d/tuxonice index 57b7bb8..f4e3de9 100755 --- a/pm/module.d/tuxonice +++ b/pm/module.d/tuxonice @@ -11,41 +11,26 @@ for loc in "/sys/power/tuxonice" "/sys/power/suspend2"; do [ -d "${loc}" ] && { TUXONICE_LOC="${loc}"; break; } done -check_suspend() -{ - [ -c /dev/pmu ] || grep -q mem /sys/power/state -} +if [ -z "$HIBERNATE_MODULE" -a -n "$TUXONICE_LOC" ] && \ + [ -f "${TUXONICE_LOC}/do_hibernate" ]; then + HIBERNATE_METHOD="tuxonice" + do_hibernate() + { + echo 5 > "${TUXONICE_LOC}/powerdown_method" + echo anything > "${TUXONICE_LOC}/do_hibernate" + } +fi -do_suspend() -{ - if [ -c /dev/pmu ]; then - pm-pmu --suspend - else - echo -n "mem" > /sys/power/state - fi -} - -check_hibernate() -{ - [ -f "${TUXONICE_LOC}/do_hibernate" ] -} - -do_hibernate() -{ - echo 5 > "${TUXONICE_LOC}/powerdown_method" - echo anything > "${TUXONICE_LOC}/do_hibernate" -} - -check_suspend_hybrid() -{ +if [ -z "$SUSPEND_HYBRID_MODULE" -a -n "$TUXONICE_LOC" ] && \ grep -q mem /sys/power/state && \ - [ -f "${TUXONICE_LOC}/do_hibernate" ] -} -do_suspend_hybrid() -{ - echo 3 >"${TUXONICE_LOC}/powerdown_method" - echo anything >"${TUXONICE_LOC}/do_hibernate" - [ -f /sys/power/tuxonice/did_suspend_to_both ] && \ - [ "$(cat /sys/power/tuxonice/did_suspend_to_both)" != "1" ] && \ - REVERSE="thaw" -} + [ -f "${TUXONICE_LOC}/do_hibernate" ]; then + SUSPEND_HYBRID_METHOD="tuxonice" + do_suspend_hybrid() + { + echo 3 >"${TUXONICE_LOC}/powerdown_method" + echo anything >"${TUXONICE_LOC}/do_hibernate" + [ -f /sys/power/tuxonice/did_suspend_to_both ] && \ + [ "$(cat /sys/power/tuxonice/did_suspend_to_both)" != "1" ] && \ + REVERSE="thaw" + } +fi |