Mac OSX Tips

Updated: July 7, 2010

Table of Contents:

Scripts

Here are a couple of useful scripts for OSX Snow Leopard. To apply the tweaks open the Terminal application and type the commands below.

Disable horizontal scrolling for Magic Mouse

Very useful if you use Adobe InDesign or Excel often:

defaults write com.apple.driver.AppleBluetoothMultitouch.mouse MouseHorizontalScroll -bool NO

Change the minimum font size in OSX mail

Very useful if you often get HTML mail from Outlook 2003 users with text that look too small:

defaults write com.apple.mail MinimumHTMLFontSize 12

Force sub-pixel antialias in OSX to be always on

OSX sometimes thinks that some newer LCD monitors do not support “LCD Font Smoothing” – using the trick below will force it to be always on like in OSX 10.5 Leopard):

defaults -currentHost write -globalDomain AppleFontSmoothing -int 2

Disable the sudden motion sensor (SMS)

if you have an SSD drive, OSX will by default always park the hard drive if the laptop is moved, which is unnecessary if you have an SSD hard drive. Disable the sudden motion sensor by typing:

sudo pmset -a sms 0

Verify that the setting has been applied correctly by typing:

pmset -g

Disable Safari webpage previews

Safari will always save each web page as a JPEG and PNG image to the folder ~/Library/Caches/com.apple.Safari. Not only will this take quite a lot of CPU and disk space, but it’s also a privacy issue since you will have images of your Google calendars etc stored for everyone to view on your hard drive. To disable this feature type the following in the terminal:

defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2

If you later would like to enable saving each web page as a JPEG and PNG image, re-enable this feature by typing the following in the terminal:

defaults delete com.apple.Safari DebugSnapshotsUpdatePolicy

Enable Spotlight within DMG files

If you like me have moved your Mail and Skype folders to an encrypted disk image you also want to add this disk image to Spotlight to enable Spotlight search. The spotlight index is stored on the encrypted volume. To enable Spotlight on a DMG image, mount the DMG image and type the following in the terminal (replace volume_name with the name of your DMG volume).

sudo mdutil -i on /Volumes/volume_name

Screenshots Location

To change the location of your screenshots, enter the following command in the Terminal (replace [path] with a folder location). You need to logout for the change to have effect.

defaults write com.apple.screencapture location [path]

Week numbers into iCal / iPhone

If you are using iCal or an iPhone you are probably aware that you can subscribe to various calendars on the web such as national holiday events. One thing missing though is the functionality to show week numbers in the calendar.

Since I use week numbers regularly in my work I need week numbers in my calendar, so I modified a script from MacOSXHints that will create week numbers that can be imported into iCal. What my script does is that it will add an all day event for the first day of the week (Monday in Europe) that shows the current week number.

Open the following page and save it as weeknumbers_2010.ics:

http://www.sanneblad.com/scripts/weeknumbers_2010.php

Double click the file weeknumbers_2010.ics to import the calendar events to iCal. Choose to import the data into a new calendar called “Week numbers” so you can easily hide or remove them if Apple some day should decide to add week numbers to iCal or the iPhone. Done!

Finally – if you want the events in Swedish style (“Vecka 31″) you can use this link instead:
http://www.sanneblad.com/scripts/veckonummer_2010.php

Remove .DS_Store files

If you want to remove hidden .DS_Store files in a folder and do not use a Finder replacement like Path Finder that can show hidden files, you can use the Terminal to easily remove the .DS_Store files using the following command:

find . -name *.DS_Store -type f -exec rm {} \;

The above command searches recursively down for all .DS_Store files and removes them without asking.

Screenshots in OSX

  • Command-Shift-3: Take a screenshot of the screen, and save it as a file on the desktop
  • Command-Shift-4, then select an area: Take a screenshot of an area and save it as a file on the desktop
  • Command-Shift-4, then space, then click a window: Take a screenshot of a window and save it as a file on the desktop
  • Command-Control-Shift-3: Take a screenshot of the screen, and save it to the clipboard
  • Command-Control-Shift-4, then select an area: Take a screenshot of an area and save it to the clipboard
  • Command-Control-Shift-4, then space, then click a window: Take a screenshot of a window and save it to the clipboard

(Snow)Leopard-specific shortcuts:

  • Space, to lock the size of the selected region and instead move it when the mouse moves
  • Shift, to resize only one edge of the selected region
  • Option, to resize the selected region with its center as the anchor point

Optimizing VMware Fusion

If you use VMware Fusion you can switch off System Restore to get extra disk space in Windows XP/Vista/7. On my 32-gb disk image I had 8.6 gb free space after installing Vista + Office 2007 + Visio 2007 + VS 2008. I switched off System Restore and suddenly I had 13.0 gb free space. Much better.

Securing Time Capsule Backups

If you like me use PGP Whole Disk Encryption to protect your Mac you might also have discovered that the Time Capsule backups are stored completely un-encrypted. This means if someone steals your Time Capsule disk they will get full access to all your emails and files, even if you have encrypted your system disk. Based on some old tips I have found on the web I have put together below a complete guide on how to encrypt and decrypt Time Capsule backups so you can use them both for backup as well as restore.

Encrypt  Backups

  • Set up Time Machine to back up to an AFP drive (Time Capsule or shared network disk).
  • Let Time Machine start backing up, then stop the back up. This will have created <machine_name>.sparsebundle on the AFP drive.
  • Disable Time Machine.
  • Open a Terminal and run these commands:
    $ cd /Volumes/<AFP Drive>/
    $ mv <machine_name>.sparsebundle <machine_name>-old.sparsebundle
    $ hdiutil convert -format UDSB -o <machine_name>.sparsebundle -encryption AES-256 <machine_name>-old.sparsebundle
  • It will ask you for a password. Type in a long password you won’t forget.
  • Double click the sparsebundle in the Finder UI. You will be prompted for your password. Type that in and tick the “Remember password” check box.
  • Open /Applications/Utilities/Keychain Access and find <machine_name>.sparsebundle. Right click it and select Copy <machine_name>.sparsebundle.
  • Select System Keychain on the left hand side of Keychain Access and paste it in the main area. Allow this action if you are asked. Remember to lock the System Keychain when you are done.
  • If you use Mac OSX 10.6 Snow Leopard, you also need to do one last thing. Open the contents of both sparsebundles (in the Finder, right-click on the sparsebundles, “Show Package Contents”). Then move the file “com.apple.TimeMachine.MachineID.plist” from the old sparsebundle to the new one.
  • Remove <machine_name>-old.sparsebundle and start Time Machine again.

Decrypt Backups for Restore

If you need to restore your backup you first need to decrypt the Time Machine backup. You do this using:

  • Mount the AFP drive on a working Mac computer (Time Capsule or shared network disk).
  • Open a Terminal and run these commands:
    $ cd /Volumes/<AFP Drive>/
    $ mv <machine_name>.sparsebundle <machine_name>-old.sparsebundle
    $ hdiutil convert -format UDSB -o <machine_name>.sparsebundle <machine_name>-old.sparsebundle
  • If you use Mac OSX 10.6 Snow Leopard, open the contents of both sparsebundles (in the Finder, right-click on the sparsebundles, “Show Package Contents”). Then move the file “com.apple.TimeMachine.MachineID.plist” from the old sparsebundle to the new one.
  • Boot your new Mac computer and choose Restore from Backup. It should find your Time Machine backup and be able to restore properly.

{ 5 comments… read them below or add one }

jorisx June 22, 2010 at 20:56
johan June 22, 2010 at 21:00

Thanks JorisX, I didn’t know about that one! I will still continue adding them my way though since I need them synced to my iPhone. But it was an interesting approach to change the date format on the system.

Marius van Witzenburg June 28, 2010 at 22:49

Your way to remove .DS_Store files will result in an error:
%find . -name *.DS_Store -type f -exec rm {} \;
find: No match.

The correct way to remove .DS_Store files:
%find . -name ‘*.DS_Store’ -type f -exec rm ‘{}’ \;

Tho its not smart to remove .DS_Store files from your Mac OS X file system since you also remove meta data that has been saved to the .DS_Store file.

In case you want to clear out the ._meta_resource files, use the following:
%dotclean

This is a default Mac OS X command for 10.6 which cleans out these files.
Again, keep in mind that you don’t do this on a mounted file system that is NOT HFS+ since this will result again in loss of your meta data.

Another thing, watch out with enabling spotlight for DMG files, lets say you have an install directory containing different installation files that might be quite large (xcode, >2GB) can result into a really slow response of Spotlight and it slows your Mac down a lot while scanning the DMG files.

This is my 50 cent addition to your blog, keep on going :-)

johan June 29, 2010 at 23:33

Hi Marius,

About DS_Store: Very weird.

If I type like I wrote on this page:
find . -name *.DS_Store -type f
I get a list of all .DS_Store files. It works just fine for me on Mac OSX 10.5 and 10.6.

If I instead type like you suggested:
find . -name ‘*.DS_Store’ -type f
I get no results

Regarding Spotlight. What I use it for is to enable searching within a specific DMG file, not all DMG files. In my case I store my Mail data, Adium and Skype data inside an encrypted DMG file and have linked the regular folders to folders within this DMG file. To be able to search emails then in Mail I have to enable Spotlight indexing inside this specific DMG file. So my tip won’t enable Spotlight to index all DMG files, it will just enable indexing of a specific DMG file used for user data.

Cheers
Johan

Marius van Witzenburg July 30, 2010 at 20:56

Oh, my bad Johan…

find . -name .DS_Store -type f

This should do the trick, the asterisk is not needed since the file starts with a dot, also you do not have to quote the name. This is only required if you use the asterisk.

Leave a Comment