Advertisement
Guest User

Untitled

a guest
May 28th, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.61 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. export TUXONICE_LOC
  4. # TODO tuxonice supports all sorts of knobs to twiddle. Since this should be as
  5. # simple as possible, it does not provide a mechanism for twiddling those knobs.
  6. # If you need more customization than this file has, consider using a hook to
  7. # set the appropriate values.
  8.  
  9. # more locations might be nice
  10. for loc in "/sys/power/tuxonice" "/sys/power/suspend2"; do
  11.     [ -d "${loc}" ] && { TUXONICE_LOC="${loc}"; break; }
  12. done
  13.  
  14. if [ -n "$TUXONICE_LOC" ]; then
  15.     toi_maybe_chvt() {
  16.     local toi_ui="$(cat "$TUXONICE_LOC/user_interface/program")"
  17.     local toi_ui_en="$(cat "$TUXONICE_LOC/user_interface/enabled")"
  18.     if [ -x "$toi_ui" ] && [ "$toi_ui_en" = 1 ] && \
  19.         ! state_exists console; then
  20.         fgconsole |savestate console
  21.         chvt 63
  22.     fi
  23.     }
  24. fi
  25.  
  26. if [ -z "$HIBERNATE_MODULE" -a -n "$TUXONICE_LOC" ] && \
  27.     [ -f "${TUXONICE_LOC}/do_hibernate" ]; then
  28.     HIBERNATE_MODULE="tuxonice"
  29.     do_hibernate()
  30.     {
  31.         toi_maybe_chvt
  32.         echo 5 > "${TUXONICE_LOC}/powerdown_method"
  33. #       echo anything > "${TUXONICE_LOC}/do_hibernate"
  34.         /usr/sbin/hibernate
  35.     }
  36. fi
  37.  
  38. if [ -z "$SUSPEND_HYBRID_MODULE" -a -n "$TUXONICE_LOC" ] && \
  39.     grep -q mem /sys/power/state && \
  40.     [ -f "${TUXONICE_LOC}/do_hibernate" ]; then
  41.     SUSPEND_HYBRID_MODULE="tuxonice"
  42.     do_suspend_hybrid()
  43.     {
  44.         toi_maybe_chvt
  45.         r=0
  46.         echo 3 >"${TUXONICE_LOC}/powerdown_method"
  47.         echo anything >"${TUXONICE_LOC}/do_hibernate"
  48.         r=$?
  49.         [ -f /sys/power/tuxonice/did_suspend_to_both ] && \
  50.             [ "$(cat /sys/power/tuxonice/did_suspend_to_both)" != "1" ] && \
  51.             REVERSE="thaw"
  52.         return $r
  53.     }
  54. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement