Install Ubuntu 13.10 on MacBook Pro with Retina Display

Mostly did the stuff here:

https://help.ubuntu.com/community/MacBookPro11-1/Saucy

Install
===========

I created an Ubuntu USB thumb drive for install. I had a previous MacBook Pro with Ubuntu on it so I just used the startup disk creator as described here: http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-ubuntu

I resized the Mac OSX partition on the MacOSX side using Disk Utility. I left only 20GB for Mac OSX and created ~200GB of free space.

I selected the option to encrypt my home directory. EncryptedHome is described here: https://help.ubuntu.com/community/EncryptedHome

Boot Management
==================

For boot management I installed [rEFIind](http://www.rodsbooks.com/refind/) on the Mac OS side. It worked out of the box and I haven't modified any settings.

Wireless
============

As written in the Ubuntu community help, the wireless would stop working after suspend/resume.
I needed to fix the wireless so I added the following script to /etc/pm/sleep.d/99_wireless_fix

I put this script in /etc/pm/sleep.d/99_wireless_fix

```bash
#!/bin/sh

# Fix wireless after suspend/resume
# See: https://help.ubuntu.com/community/MacBookPro11-1/Saucy#wireless
case "$1" in
    resume|thaw)
        service network-manager stop
        rm /var/lib/NetworkManager/NetworkManager.state
        service network-manager start
    ;;
esac
```

Speakers
=============

The speakers didn't work after suspend/resume.

I put this script in /etc/pm/sleep.d/99_speakers_fix

```bash
#!/bin/sh
# Fix speakers after suspend/resume
# See: https://help.ubuntu.com/community/MacBookPro11-1/Saucy#Speakers
case "$1" in
    resume|thaw)
        hda-verb /dev/snd/hwC1D0 0x1 set_gpio_mask 1
        sleep 1
        hda-verb /dev/snd/hwC1D0 0x1 set_gpio_direction 1
        sleep 1
        hda-verb /dev/snd/hwC1D0 0x1 set_gpio_data 1
        ;;
esac
```

SATA
==========

I got error messages when shutting down that looked like this:

    [  882.793794] ata1: exception Emask 0x10 SAct 0x0 SErr 0x10000 action 0xe frozen
    [  882.793798] ata1: irq_stat 0x00400000, PHY RDY changed
    [  882.793799] ata1: SError: { PHYRdyChg }
    [  882.793803] ata1: hard resetting link

I didn't have any real problems but this kind of thing could possible corrupt data so I wanted to fix it.

SATA controllers can be set in different modes for high performance (when connected to a power supply) and for low power (when running on a battery). I found that there is a bug in the SATA controller when the SATA drive is set for maximum performance.

https://bugzilla.kernel.org/show_bug.cgi?id=62351

The workaround was to create a power management script to keep the SATA drive in low power.

I put this script in /etc/pm/power.d/sata_alpm

This is a copy of the script found at /usr/lib/pm-utils/power.d/sata_alpm. That script changes the
power mode when the power adapter is connected/disconnected but I modified it so that the
drive always runs in low power mode.

```bash
#!/bin/sh

. "${PM_FUNCTIONS}"

SATA_ALPM_ENABLE=${SATA_ALPM_ENABLE:-false}

help() {
cat <<EOF
$0: SATA link power management

This hook tries to save power by allowing SATA controllers to
reduce power usage when the SATA subsystem is otherwise idle.

This adds a little bit of latency to drive accesses in
exchange for moderate power savings if you are not using the drive.

This hook has 1 parameter:
SATA_ALPM_ENABLE = whether to use SATA ALPM on battery.
Defaults to "false".

EOF
}

set_sata_alpm() {
    # see kernel commit 6013efd8860bf15c1f86f365332642cfe557152f
    kv="$(uname -r)"
    [ "$kv" ] || exit $NA  #for paranoia's sake
    [ "${kv%-*}" \< "2.6.33" ] && exit $NA  # avoid fs corruption
    for f in /sys/class/scsi_host/host*; do
	[ -w "$f/link_power_management_policy" ] || continue
	printf "Setting SATA ALPM on %s to %s..." "${f##*/}" "$1"
	echo "$1" > "$f/link_power_management_policy" && echo Done. || \
	    echo Failed.
    done
}

case $1 in
    true) [ "$SATA_ALPM_ENABLE" = true ] && set_sata_alpm min_power;;
    # Commented out to fix SATA issues.
    # See: https://bugzilla.kernel.org/show_bug.cgi?id=62351
    #false) set_sata_alpm max_performance;;
    false) set_sata_alpm min_power;;
    help) help;;
    *) exit $NA;;
esac

exit 0
```

Keyboard
=============

I heavily modify the keyboard so I didn't do anything related to keyboard layout.

My keyboard layout is described here (Japanese): http://www.ianlewis.org/jp/japanese-106-key-dvorak-keyboard-layout

ICC Profile
=============

I installed the Mac OS ICC profile as described in the Ubuntu community document:
https://help.ubuntu.com/community/MacBookPro11-1/Saucy#Retina_display_ICC_profile

Small Pixels
=============

Window Borders
-------------------

I increased the border size of windows and increased the text size as explained here:

https://help.ubuntu.com/community/MacBookPro11-1/Saucy#Issues_due_to_tiny_pixels_on_the_retina_display

I edited /usr/share/themes/Ambiance/metacity-1/metacity-theme-1.xml and changed the following settings under <frame_geometry name="frame_geometry_normal" ...>

```xml
<distance name="left_width" value="4"/>
<distance name="right_width" value="4"/>
<distance name="bottom_height" value="4"/>
```

Gnome
--------------

I increased size of text in gnome but I prefer to keep the text a bit smaller than the size in the original article, so I set the text scaling factor to 1.2 rather than 1.8:

     gsettings set org.gnome.desktop.interface text-scaling-factor 1.2

Chrome
-----------

I increased the default zoom in Chrome to 120% under the settings.

Unity
--------

The Unity sidebar buttons are pretty small so you can change it by increasing the System Settings => Display => Launcher Icon Size.