MacBook Hibernation Weirdness

My new MBP (ML 10.8.2) has an unexpected morning behavior.  Instead of just popping the lid and getting started, I’m now treated to the “wake from hibernation” screen, and it takes a minute or two to get working.
Image of wake up progress bar
Apparently there’s some new power management thing going on,  so it’s time to poke around in the power management settings, if only to understand what’s going on.  You can see all your current power management settings from Terminal using “sudo pmset -g”. You will need to enter your admin password.

Here’s the pmset -g result on my MacBook Pro:
Active Profiles:
Battery Power        -1
AC Power        -1*
Currently in use:
standbydelay         4200
standby              0
womp                 1
sms                  1
hibernatefile        /var/vm/sleepimage
gpuswitch            2
halfdim              1
networkoversleep     0
disksleep            10
sleep                0 (sleep prevented by )
autopoweroffdelay    14400
hibernatemode        3
autopoweroff         1
ttyskeepawake        1
displaysleep         0
acwake               0
lidwake              1

This is all very interesting and worth reading through the man pages (“man pmset”). For my situation, I believe the issue is “autopoweroff” (the man page for pmset is silent on autopoweroff and autopoweroffdelay), which apparently sends the Mac into hibernation, after saving the contents of RAM, after the “autopoweroffdelay”.   The default autopoweroffdelay is 14400 (seconds), which is four hours.  Setting autopoweroff to 0 would turn it off, which I do not think would be desirable.  You want the system to hibernate after a reasonable interval in order to maximize battery power.  But I want more than 4 hours before hibernation, since it takes rather a long time to wake up, especially if you have a bunch of things open when the system sleeps…
open apps
I changed my autopoweroffdelay to 12 hours (43200 seconds), so the system will not be in hibernation after I wake up from my own personal slumber, which is somewhat less than 12 hours.  If the system is inactive for more than 12 hours, it will still save the contents of RAM to the hard disc, hibernate, and save battery power. The command from Terminal is “sudo pmset -a autopoweroffdelay 43200”  I tested this with shorter settings for autopoweroffdelay, and confirmed that this addresses the problem. The -a option for pmset applies the settings to both ac and battery operation; you could be more granular if you like.

How to save man pages from Terminal

One would expect it should be easy to save a man page from terminal for review, and it is, but it doesn’t work the way you expect.

I would expect that “man col > col.txt” should save a nice text file in the home directory, but the results are strange:

COL(1)              BSD General Commands Manual            COL(1)

NNAAMMEE
ccooll — filter reverse line feeds from input

SSYYNNOOPPSSIISS
ccooll [--bbffhhppxx] [--ll _n_u_m]

DDEESSCCRRIIPPTTIIOONN
The ccooll utility filters out reverse (and half reverse) line feeds so that
the output is in the correct order with only forward and half forward
line feeds, and replaces white-space characters with tabs where possible.

Similarly, trying to open the man pages using “man col | open -f” dutifully opens the mangled file in TextEdit.

The repeated characters are fossil behaviors from the days when bolding was accomplished by repeatedly backspacing and overprinting characters.  The col utility is the workaround for this behavior. The man for col says:

The col utility filters out reverse (and half reverse) line feeds so that
the output is in the correct order with only forward and half forward
line feeds, and replaces white-space characters with tabs where possible.

And we need to use the -b option :
-b      Do not output any backspaces, printing only the last character
written to each column position.

So to redirect the man file to a text file, use

man col | col -b > col.txt

which pipes ( | ) the man pages to the col utility, without backspaces, and then redirects it to a text file.  To open the man for col in TextEdit, use

man col | col -b | open -f

(The -f option for open sends to the default text editor.)

If you want the man pages as PDF, try:

man -t [your_command_name_here] | open -f -a Preview

This provides a nice looking output that respects the bolding.  The -t option for man formats the output as PostScript; the -a option for open lets you specify the application (Preview).