Safe Sleep on OS X

I love Sleep on OS X. Compared to Hibernate in Windows or Software Suspend in Linux, I prefer it. Not only does it take only 2-3 seconds to sleep, but it wakes in about the same amount of time. I’ve only got one problem with it though: If I pull out the battery, there goes my suspended session. I’ve got to boot and log back in (while it only takes a minute or two, it’s a pain once you’re used to 2-3 seconds). The new powerbooks include a Safe Sleep mode which dumps the RAM to disk, allowing a session to survive a power failure (such as a dead battery, or swapping out the battery) in a machine. It’s a pretty handy feature in my opinion.

Today, I stumbled across a couple sites that explain how to enable this for older machines. Andrew Escobar has a nice write up but it doesn’t work if you are using the screen-spanning hack on an iBook. Matt Johnston has the writeup that Andrew based his on, along with a few scripts that automate the process for you (along with one that allows you to use screen-spanning and Safe Sleep.

There’s two modes for Safe Sleep, you can set it up to go into Safe Sleep when the power is low, or to Safe Sleep each time you sleep the machine. I’ve played with it going into Safe Sleep each time I sleep the machine, it takes about 10-15 seconds and the sleep light doesn’t come on (you have to wake it via the power button) and it took about 30-45 seconds to return to my desktop. I’m currently draining the battery now to make sure that it works (I really want to be able to swap out the battery without a reboot since I have a spare). I’ll update on the status of that a bit later.

Update: It does work when the laptop sleeps itself. I’ve found this isn’t particularly handy though as it only does it when the battery is drained. So, once you do this once, you’ve got a drained battery and no way to charge it.

So, what I’ve done is create two scripts, one to enable Safe Sleep every time the laptop sleeps and one to enable it only when the battery is low. I run the first, wait for it to sleep and then pull the battery. Afterwards, I run the second so that it will sleep normally.

I’ve mirrored Matt’s scripts locally here, and my two scripts are here.

What is Open Source?

Tim seemed to take exception to my statement that the Apple kernel is open source.

“So with that Open Sourced Kernel I’ll be able to get all of those nifty new things that Apple added in then right? I’ll believe it when I see it. Being a part of Open Source means giving back to the community, not just taking the ball and running with it.”

Actually, I never claimed that Apple was part of the open source community. They’re not and I don’t blame them for it. They don’t feel the “Open Source spirit” either. They do however, follow the licenses of the open source software they use. Yeah, the KHTML team may not be happy with them, but Cnet quotes one of the team members as saying:

“Another said that while Apple had stuck to the letter of the license in fulfilling its obligations to the KHTML project, the two groups were now all but estranged. … Apple is not all about Open Source; ask the KHTML development team if you are in doubt about that. Sure, you can use a lot of your favorite Linux apps on OS X, but you can do the same on Windows.”

Tim and I had a chat last night that lasted about an hour and a half. We both agree that Apple doesn’t relinquish their right to their software patents. He believes that since you would have to license Apple’s patents to use their code to implement those patented processes, it is not open source. I disagree, and I’ll explain why.

First, a clarification. When a company receives a software patent, they have the right to license that to who they see fit. Whether we talk about Apple’s spring-loaded folders or something else, even if you write your own code to implement that patented item, it must be licensed from the patent holder.

Now, I’ll present my arguement as to why Apple’s kernel is open source. The Open Source Initiative is an organization that was founded in 1998 by Bruce Perens and Eric S. Raymond. OSI has published a definition of what Open Source is that I agree with:

“The Open Source Definition

Introduction

Open source doesn’t just mean access to the source code. The distribution terms of open-source software must comply with the following criteria:

1. Free Redistribution

The license shall not restrict any party from selling or giving away the software as a component of an aggregate software distribution containing programs from several different sources. The license shall not require a royalty or other fee for such sale.

2. Source Code

The program must include source code, and must allow distribution in source code as well as compiled form. Where some form of a product is not distributed with source code, there must be a well-publicized means of obtaining the source code for no more than a reasonable reproduction cost preferably, downloading via the Internet without charge. The source code must be the preferred form in which a programmer would modify the program. Deliberately obfuscated source code is not allowed. Intermediate forms such as the output of a preprocessor or translator are not allowed.

3. Derived Works

The license must allow modifications and derived works, and must allow them to be distributed under the same terms as the license of the original software.

4. Integrity of The Author’s Source Code

The license may restrict source-code from being distributed in modified form only if the license allows the distribution of “patch files” with the source code for the purpose of modifying the program at build time. The license must explicitly permit distribution of software built from modified source code. The license may require derived works to carry a different name or version number from the original software.

5. No Discrimination Against Persons or Groups

The license must not discriminate against any person or group of persons.

6. No Discrimination Against Fields of Endeavor

The license must not restrict anyone from making use of the program in a specific field of endeavor. For example, it may not restrict the program from being used in a business, or from being used for genetic research.

7. Distribution of License

The rights attached to the program must apply to all to whom the program is redistributed without the need for execution of an additional license by those parties.

8. License Must Not Be Specific to a Product

The rights attached to the program must not depend on the program’s being part of a particular software distribution. If the program is extracted from that distribution and used or distributed within the terms of the program’s license, all parties to whom the program is redistributed should have the same rights as those that are granted in conjunction with the original software distribution.

9. License Must Not Restrict Other Software

The license must not place restrictions on other software that is distributed along with the licensed software. For example, the license must not insist that all other programs distributed on the same medium must be open-source software.

*10. License Must Be Technology-Neutral

No provision of the license may be predicated on any individual technology or style of interface.”

Another thing that OSI does is vet licenses that claim to release code as, “Open Source.” They even publish a list of approved licenses. Right in the copy of the license that they display on their website is the section that Tim finds so contentious:

5. Limitations on Patent License. Except as expressly stated in
Section 2, no other patent rights, express or implied, are granted by
Apple herein. Modifications and/or Larger Works may require additional
patent licenses from Apple which Apple may grant in its sole
discretion.

Open Source is about setting the terms of copyright so that your code can be modified, used and redistributed (among other things listed above). It is not about patents. While I believe that software patents should have a very short term (no more than a year or two as software is a fast moving field, much faster than say, manufacturing) they are valid, legal and useful.

Were Apple not to publish their code, as a programmer, you would still have to license the patent to implement that feature. But, code and licenses are covered by copyright law, patents have their own body of law.

“Where is my officially supported method of syncing my 2 iPods under Linux? Where is my iTunes Music Store access for Linux?”

Well, it’s a business. Why don’t you ask Steve Jobs to do a cost/benefit analysis on doing it? Don’t forget to ask what the RIAA’s affect on his decision is.

OS X… unworthy of respect?

Jorge had an interesting post today about OS X and open source advocates. It got me thinking, and when that happens, well… stuff like this shows up.

Yeah, OS X users do get a “Get Out of Jail Free” card in comparison to Windows users. I started wondering why this was, and here’s what I came up with:

  • For the technically capable, OS X is a choice that says, “I looked and decided this was the best choice for me.” Windows though, well… I’m just going to assume that you’re one 31337 k1dd13.
  • Open Source kernel. Flame the, “BSD underpinnings” remarks if you will, but the kernel is open.
  • Availability of open source utilities. OS X has stuff built in (openldap, gcc, etc) and it has plenty more easily available to it. Running them isn’t like getting Cygwin on Windows.
  • Command line… Windows doesn’t have a fully functioning command line. I’m sorry, but if I need to do something important, I want a command line with a text based login. Who knows where I’ll be and whether or not I’ll have the bandwidth to use a fancy GUI remote use package (RDP, terminal services, whatever)..
  • Security, OS X has it by default. Viruses, what are those?
  • Stability.
    elayne:~ kyle$ uptime
    23:31 up 28 days, 54 mins, 2 users, load averages: 0.44 0.37 0.53

    My laptop has been up a month… enough said.

  • Sane application installs. Hey look, the program is all in one file as far as the user is concerned. Granted, this is really only an advantage over Windows, I prefer Linux package management via apt. Then, I don’t even have to care where something gets installed to.
  • So, why don’t OS X users get ostracized like Windows users? An operating system is ultimately about choice. At ~5% of the market share, OS X is a choice, Windows is a default. Also, while Jorge says the goal wasn’t originally, “Linux on the Desktop,” maybe, just maybe it should be. Maybe people want usability out of their machine. I know that is where Ubuntu is headed and I sure as hell like what that group is using.

    My name is Kyle, I use both OS X and Ubuntu Linux; I believe the goal of Linux should be making it usable as a Desktop.

    Sad iPod

    My iPod has given up the ghost. I’ve been fighting with it for a while now and today, I was squarely beaten. I was listening to a couple of Beethoven’s symphonies today (3rd and 7th if you want to know) and turned it off when I got to class. As usual, I put it in my pocket for the rest of the day. This was at noon.

    Fast forward to 4:30pm. I just got out of my last class for the day and am sitting in my car. The iPod goes in the cupholder, the FM transmitter is attached. I use the menu to navigate to a song in my playlist of rock music and the iPod freezes. I mentally groan and am annoyed to have to fuss with it before I head home. I reset it and it goes through its booting menu… this time though, I’m not greeted by the normal menu. Oh no, I get this:

    Sad iPod

    I’m still within the standard one year warranty (I didn’t buy AppleCare for my iPod) so I’ve submitted the web form to get a replacement. It turns out, since I’m past 6 months, I have to pay shipping, to the tune of $30. Oh well, that’s $30 for a new iPod, it’s better than $299.

    Hopefully the turn around is less than a week, I’m already missing it.

    Planet

    Well, over the past couple of days, I’ve been working on getting Planet set up to aggregate all of my feeds into one massive feed.

    Over the same time period though, I’ve been playing around with OS X Tiger’s Safari RSS, and I must say that I’m quite impressed. It lets you view feeds individually, or will aggregate them into one large, searchable and categorizable feed. It’s really pretty slick.

    But, I digress, I ended up setting up a number of Planet feeds, a couple for MTU LUG and a couple for myself.

  • MTU LUG’s member’s blogs
  • An aggregation of all of MTU LUG’s RSS feeds
  • My own personal news feed from a large number of news sources
  • A aggregated feed of most of my friend’s blogs.
  • All in all, Planet is pretty cool… it has some rough edges, but it’s pretty easy to figure out once you realize where the templates are that the config files are pointing at. Now I just need to learn some CSS stuff so I can make it look better.