Setting Environment Variables with Spaces in OS X 10.8 (Mountain Lion)…

For setting the PATH and other environment variables, see here, since it will explain the more appropriate place for them.

Unfortunately, the methods listed in the linked article above don’t work for environment variables with spaces, e.g. MAVEN_OPTS="-Djavax.net.ssl.trustStore=keystore -Djavax.net.ssl.trustStorePassword=password".

To set these, the variables have to be configured as launch daemon arguments.  Here is an example of a file I have:

$ cat /Library/LaunchDaemons/mavenopts.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
	"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>MAVEN_OPTS</string>
	<key>ProgramArguments</key>
	<array>
		<string>launchctl</string>
		<string>setenv</string>
		<string>MAVEN_OPTS</string>
		<string>-Djavax.net.ssl.trustStore=keystore -Djavax.net.ssl.trustStorePassword=password</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>KeepAlive</key>
	<true/>
	<key>LaunchOnlyOnce</key>
	<true/>
</dict>
</plist>

This file can also go in /System/Library/LaunchDaemons instead of /Library/LaunchDaemons, but this is more a matter of philosophy; either location will work.

For more details, here is the Apple documentation: http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html#//apple_ref/doc/uid/10000172i-SW7-BCIEDDBJ

Setting up Nike Missions with an iPod Nano

This was a little annoying to set up, but these are my recommended steps (assuming iPod Nano and iTunes have already been sync’d at least once for music and other media):

  1. Set up Nike+ account by doing the following:
    1. Go to http://www.nikeplus.com in the default browser
    2. Create an account if one does not already exit
    3. Log in and leave the browser logged in
  2. Register a run on the iPod Nano by doing the following (it must be a run, not a walk):
    1. Tap “Fitness”
    2. Tap “Run”
    3. Tap “Basic”
    4. Tap “None”
    5. Tap “Start Workout”
    6. Shake the device a little bit to register some activity
    7. Tap the pause button
    8. Tap “End Workout”
  3. Sync the iPod with iTunes.  iTunes should prompt whether Nike+ data should be uploaded automatically or not.  This can be changed later by going to the Nike tab under the device settings and checking or unchecking the box.
  4. Once the iPod has been sync’d, the device should be registered with Nike and should be recognized for Nike Missions (http://missions.nike.com)

After registering for Nike Missions and clicking through the introduction screens, a screen should be found that has a button to start a mission.  Clicking this button seems to start the timer (i.e. if the mission were to earn 300 points in 30 minutes, the 30 minute timer would start as soon as the button was clicked), so I’m not sure how this is supposed to work with the iPod Nano since it has no wireless synchronizing capabilities.  For someone like me who carries their iPod to work and sync’s it at home, I’m assuming runs could be registered on the device during the day, a mission timer started in the evening at home, and a sync performed at home while the timer is running.  Time to try it out!

Setting Environment Variables in OS X 10.8 (Mountain Lion)

I was recently trying to install SQL Developer from Oracle and wanted the LDAP function to work, which would require the application to be aware of my ORACLE_HOME, but I could not get the application to become aware of the environment variable when I launched it from the Launcher or the Dock.

Shell Variables

For environment variables that are only going to be used in the terminal, setting them in the .bash_profile is sufficient.  I’m not totally sure how the OS X shell works, but it seems to only read the .bash_profile (doesn’t seem to read .bashrc etc.), and it reads it every time a new terminal is open.

Example

PATH=${PATH}:${HOME}/scripts; export PATH

The problem with using the .bash_profile is that applications in the GUI are not aware of the environment variables (e.g. in my case, launching SQL Developer from the command line activated the features I wanted, but clicking the icon from the Launcher did not activate the features).

Environment Variables

There used to be a mechanism for setting environment variables prior to Mountain Lion by setting them in the ${HOME}/.MacOSX/environment.plist file, but this doesn’t seem to work in Mountain Lion.  They have to be set via launchd in /etc/launchd.conf. Unfortunately, this can’t be done at a user level at the moment (${HOME}/.launchd.conf not currently supported), so it must be done at a global level (affects all users).

Example

setenv ORACLE_HOME /opt/oracle

Path Variables

There is one more way to set the PATH globally for all users. It can be done by adding directories that should be in the path into files under the /etc/paths.d directory.

Example

Here is an example of a file that might be called /etc/paths.d/oracle.

/opt/oracle/bin

Google Chrome: Could Not Load Shockwave Flash

I recently started getting this error on my MacBook, but had no idea why.  I hoped it would fix itself with a Chrome update or something, but that never happened.  I didn’t really mind since the only change to me was that the fan on my MacBook Air wasn’t kicking in whenever I was on a site with a Flash ad.

This finally affected me negatively when I was trying to upload some photos to print at Walgreens.com.  I got the yellow error banner stating, “Could Not Load Shockwave Flash.”  After delving into the issue, I discovered this fix:

  1. In the address bar, go to chrome://plugins
  2. If you have the same issue I did, you should see “Flash (2 files)…” listed.  When you click the Details button in the top-right corner to expand all the entries, you should now see two entries under the “Flash (2 files)…” heading.
  3. Disable the Flash plugin internal to Chrome (the Location entry should be something like /Applications/Google Chrome.app...
  4. Refresh your page!

Locking Your Mac

I previously thought the only way to lock my MacBook was to wait for the screen saver to turn on or to log out out the machine.  This was an annoyance since I was used to being able to lock my laptop with a single key combination in Windows.  However, I’ve found there is a better way!

First, open the Keychain Access application. This can be done a few different ways:

  • In Finder: Applications > Utilities > Keychain Access
  • In Launchpad: Utilities > Keychain Access
  • Search for “Keychain Access” using Spotlight

Once Keychain Access is open, open the Preferences window from the application menu and check the box labeled “Show keychain status in menu bar.” There should now be a lock icon in the menu bar that should have a Lock Screen option when clicked!

Triple Booting a Macbook Air

Download Windows 7 Bootcamp Drivers

It is possible to download the Windows 7 drivers with the Boot Camp Assistant, but I could never get this to work (the progress bar never passed 20%), so I had to use the alternate method below.

Download and Install Driver Package

Follow this link (http://swscan.apple.com/content/catalogs/others/index-lion.merged-1.sucatalog) and search for BootCampESD.pkg. There were two entries listed when I did this, so I picked the one with the more recent value between the date tags, which was pointing here: http://swcdn.apple.com/content/downloads/63/18/041-4777/GRGxJTrxPTSTdbBKFXt2bVjqVJGvBknRC3/BootCampESD.pkg

After downloading the file, simply double-click it to run it.

Copy Drivers to USB Flash Drive

After the install is complete, navigate to /Library/Application Support/BootCamp and double-click the WindowsSupport.dmg file to mount it. After the file is mounted, copy the contents to a USB drive for later.

Download and Install rEFIt

Download rEFIt from the website (http://refit.sourceforge.net/). It will make the whole process much easier. When the download is complete, simply double-click the dmg file to mount it and run the rEFIt.mpkg file to install.

When the install is complete, reboot the machine. I had to reboot twice before the change took effect (not sure why this was the case). It will be clear when rEFIt has taken over because the boot screen will have multiple graphical icons.

Partition Hard Drive

OS X supports live partition resizing, so the partitioning can simply be done using Disk Utility. Open Disk Utility, click the hard drive (not the partitions) on the left pane (mine says “251 GB APPLE SSD…”), click the Partition tab on the top, and add two partitions by clicking the + button near the bottom.

Both new partitions should be formatted as FAT and should be labeled clearly. I made a 50GB partition labeled WINDOWS and a 100GB partition LINUX while leaving my OS X partition at 100GB.

Install Windows 7

I think a USB flash drive can be used somehow, but I happen to have a USB DVD burner, so I used this instead for simplicity.

With the optical drive connected and the Windows install disk in the drive, reboot the Mac and press and hold the option key when the computer turns on. There should be a picture of an optical disk labeled WINDOWS that should be selected. It might take a little while (~30 seconds) for the system to find the disk if it does not appear right away.

Click through the first few steps until you are able to choose Custom Install. Select the partition labeled WINDOWS, format it as NTFS (you may have to click some link to enable advanced features to be able to do this), and click through the rest of the install process. This should be pretty straight-forward.  You should be able to select the WINDOWS partition whenever you need to reboot at the rEFIt screen.

When the Windows installation is complete, install the drivers that were copied to the USB drive earlier.

Remove Linux Partition

This step isn’t really necessary if the desired Linux partitioning is known, but it makes the process easier.

Disk Utility will be used as earlier (which means the computer has to be booted into OS X), but instead of clicking the + button, the - button should be clicked to delete the LINUX partition and leave it as empty space.

Install Fedora 16

This was by far the most challenging part to get right, but hopefully this will make it pretty straight-forward.

Download Fedora DVD

The first step is to download the install DVD (the Live CD WILL NOT WORK!!!). The DVD apparently has extra EFI capabilities that the Live CD doesn’t come with. It was a little hard for me to find the link, but it is here: http://fedoraproject.org/en/get-fedora-all. Near the bottom of the same page, there are links for torrent downloads, which might work faster.

Install Fedora 16

Insert the Fedora 16 DVD into the drive and reboot the computer, pressing the option key when the computer powers on. Two optical disk images may pop up, but the one labeled WINDOWS should be the one selected.

When the Fedora installer comes up, press the tab key and follow the steps displayed on the screen to add the nomodeset kernel parameter. The screen may remain black for a few minutes, but the installer should start up. When prompted, select the “Use Free Space” option if the LINUX partition was removed earlier, otherwise the partitions should manually be set.

When prompted, the boot loader should be installed to the disk (mine was /dev/sda), not the partition.

Sync MBR

After the Fedora installer is complete, cycle through the icons at the rEFIt screen and select the MBR tool. It should state that the MBR is out of sync, so it should be synced up. I only had to sync up the MBR once, but again, I had to restart twice for this to take effect for some reason.

After the computer reboots, all operating systems should be successfully installed. At the rEFIt screen, selecting Linux or Windows should boot into the Grub2 menu, at which point the proper OS can be selected.

Optional: Remove rEFIt

Because selecting Linux and Windows both led to the Grub2 screen, I thought having rEFIt was redundant. rEFIt can be easily removed by booting into OS X, selecting the OS X hard drive in Startup Disk to bless it, and removing the /efi folder.

If rEFIt is removed, the option has to be held when the computer boots and the WINDOWS hard drive selected in order to see the Grub2 menu.

Fedora Tweaks

Enable WiFi

WiFi and sound do not work out of the box. I was able to connect to the Internet via my phone over Bluetooth, but a USB Ethernet dongle can also be used. A simple yum update and reboot should enable the WiFi.

Enable Latest nVidia and WiFi drivers with RPM Fusion

The free and nonfree RPM Fusion repos should added by following the instructions at the RPM Fusion website: http://rpmfusion.org/

After the repos are added, run yum install kmod-nvidia kmod-wl. yum info kmod-nvidia and yum info kmod-wl can be used for more information on these packages, but they are just downloading the latest nVidia and WiFi drivers.

After the packages are done installing and the system is rebooted, the resolution should be set properly.

Enabled Sound

The sound modules all get loaded correctly, but the speakers seem to be muted for some reason. Run alsamixer -c0 as your user (does not have to be done as root) and make sure the main speakers are not set to MM. This can be toggled by selecting the main speakers with the arrow keys and pressing the m key. The up and down arrows can be used to set the speakers to the desired level. I set mine to 60.

When this is done, run alsactl store 0 as root. Reboot just to make sure everything still works, but it should.

Enable Two-Finger Scrolling

Two-finger scrolling is not enabled by default, but thankfully the only tweaking necessary here is clicking the two-finger scrolling checkbox in the mouse settings tool.

Other Notes

The brightness keys do not work. I have not tested any “advanced” functions like hibernate, stand by, etc.

OS X Lion Boot Camp Windows Drivers

I was trying to install Windows 7 via Boot Camp on a MacBook, but the Boot Camp Assistant was not downloading the drivers.  It was getting stuck at about 20% and would not budge.  I found a discussion page (https://discussions.apple.com/message/16605226#16605226) that had a manual download link here.

General Apple Boot Camp support (http://www.apple.com/support/bootcamp/) was pretty good, but it did not have this link.

Burning an OS X Lion Install DVD

I have a 3rd generation MacBook Air running Snow Leopard that I wanted to upgrade to Lion via a clean install.  To do this, I wanted to burn a DVD that I would be able to use on my other MacBook as well.  There are many guides online (here’s a good one from Lifehacker: http://lifehacker.com/5823096/how-to-burn-your-own-lion-install-dvd-or-flash-drive), but I couldn’t get the DVD I burned to boot!  I also found an InstallESD.dmg inside the InstallESD.dmg the guide says to burn, but this did not work for me as well.  In the end, I ended up having to use the flash drive method.  Good luck!

Here are the md5sums of the files I tried to burn:

InstallESD.dmg (external) 5a8bc4c636f35c855250c7b5508ae7a5
InstallESD.dmg (inside dmg above) 412cee9c4c77c04c9c8489c363a7e2e4

BAD SUPERBLOCK: MAGIC NUMBER WRONG

I was asked to take a look at a MacBook that was only showing a folder with a question mark instead of booting up.  I was hoping it would be an easy fix, but unfortunately, that was not the case.  Apple actually has very good support documentation (http://support.apple.com/kb/ts1440), but unfortunately none of these steps worked for me.  For anyone else in the same situation, I also recommend looking into the fsck and newfs commands, but these commands did not help me either, other than reporting the BAD SUPERBLOCK: MAGIC NUMBER WRONG error.

Good software deserves its recognition, and what I eventually had to do was use an awesome program: Data Rescue 3 (http://www.prosofteng.com/).  Just some quick comments:

  • installation was easy since the program is a “good Mac citizen” (only involves being dragged to the Applications folder)
  • interface was intuitive and easy and pretty much only involved selecting the disk I wanted to recover and the different recovery methods
  • I eventually had to use the “deep scan” method, which took a few hours (mentioned clearly in the interface), but afterwards all the recovered files were organized nicely by type (e.g. Music, Documents, etc.) and were restored with just a few clicks

In hindsight, using Data Rescue 3 was similar to the Mac experience.  There was a premium to pay, but in the end, it just worked.

Taking Screenshots with OS X

Use the following key combinations to take a screenshot and save it to the desktop:

  • Command + Shift + 3: full screen screenshot
  • Command + Shift + 4:
    • select an area: selected area screenshot
    • space: selected application windows screenshot

Add “Control” to any of the key combinations above to take the same screenshot and copy it to the clipboard instead of the desktop.