Posts Tagged ‘osx’

Sleep Display Script

Here’s a quick script I cooked up to turn off the blinding light that is my iMac display when I go to bed at night.

QuickSilver Display Sleep 1 Minute

Features:

  • Runs great from Quicksilver.
  • Talks to you. (May not be a feature.)
  • Doesn’t require administrative rights.
  #!/bin/bash
  # Jeff McCune 
  export CURRENT_DELAY=$(pmset -g | grep displaysleep | awk '{print $2}')
  # Charger or Battery Flag.
  pmset -g | grep -q '^AC.*\*' && export MODE="-c" || export MODE="-b"
  say "The display will shut off in about 90 seconds" &
  # force allows this to work for non-admin users.
  pmset force $MODE displaysleep 1
  # Quicksilver blocks until script completion.  Fork off the reset command.
  bash -c 'sleep 120; pmset force $MODE displaysleep $CURRENT_DELAY' &
  exit 0
 

Manually Migrate Tiger FileVault sparseimage to Leopard FileVault sparsebundle

So I’m finally running Mac OS X 10.5 Leopard on my portable. I’ve decided to migrate to the new sparsebundle style FileVault image, and here’s how I did it:

First, make sure you’ve created a FileVault master certificate by setting a master password in the Security preference pane.

Manually create the sparse bundle:

umask 077
export NAME="mccune"
hdiutil create -size 300g \
  -encryption -agentpass \
  -certificate /Library/Keychains/FileVaultMaster.cer \
  -uid 502 -gid 20 -mode 0700 \
  -fs "HFS+J" \
  -type SPARSEBUNDLE \
  -layout SPUD \
  -volname "$NAME" \
  "$NAME".sparsebundle;
chown -R "$NAME":staff "$NAME".sparsebundle

Make sure to set the password on the disk image the same as the password used with the user account, otherwise the system won’t be able to decrypt the image from the loginwindow.

Mount the sparsebundle:

hdiutil mount -owners on -mountrandom /tmp -stdinpass "$NAME".sparsebundle

Copy the contents of your home directory:

rsync -avxHE --progress /Users/mccune/ /tmp/dmg.TYSCwg/

After I did the initial pass with rsync, I logged out of my user account, and logged in using the administrator account in order to run the rsync process a second time, while my profile was in a steady state.