So my grad school gave me a free MacBook Pro 9.2, but I am a die-hard Linux fanboy. I thus gathered information and installed Arch on a MacBook:

Some boot keycodes

  • Hold alt while booting to display the startup manager (you can select your boot device here).
  • Hold ctrl while selecting a boot device (choose your EFI partition) to permanently boot from that one.
  • Hold cmd+R while starting to start a recovery. If you have a OS X recovery partition, this is a recovery wizard (restore from time machine, reinstall OS X, disk utility). If you don’t, it starts a complete internet recovery ((almost?) restore factory defaults). It even restores your EFI NVRAM thingy, I think.

Some Mac OS X things

Eduroam

Download from here the files lrz.eduroam.profil.mobileconfig and lrz.vpn.profile.mobileconfig. Doubleclick them in OS X and enter your password a few times.

Arch Linux (dual boot with OS X) on a MacBook Pro 9.2

These two guides are gold, and in the following, I just highly summarized the procedure from here:

Also, the (long) Beginner’s guide and (condensed) Installation guide are awesome:

Preparation

  • From within OS X, Shrink your OS X partition to like 100GB.
  • Don’t install rEFInd yet. I’d do that from within Arch later.
  • Get a ‘‘wired’’ internet connection.

The normal Arch installation

Boot into Arch (USB stick), run cgdisk. Delete the OS X recovery partition, if you like. (leave the EFI partition intact!) Then create your Arch partition(s), set it to type “Linux”. Then:

mkfs.ext4 /dev/sda4
mount /dev/sda4 /mnt
mkdir -p /mnt/boot/efi
mount /dev/sda1 /mnt/boot/efi
mkdir /mnt/mnt/osx
mount /dev/sda2 /mnt/mnt/osx
 
ping google.de
pacstrap /mnt base
genfstab -U -p /mnt >> /mnt/etc/fstab
arch-chroot /mnt
 
echo "macbook" > /etc/hostname
ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime
vi /etc/locale.gen  # uncomment de and en_US, both UTF-8
locale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
vi /etc/vconsole.conf  # enter the following two lines:
# KEYMAP=de-latin1
# FONT=Lat2-Terminus16
 
mkinitcpio -p linux
passwd
pacman -Syyu
pacman -S grub-efi-x86_64 efibootmgr
 
modprobe dm-mod
mount -t efivarfs efivarfs /sys/firmware/efi/efivars
# I *think* you might not even need the following line, rEFInd can work without GRUB
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck --debug
mkdir -p /boot/grub/locale
cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo
 
refind-install
cd /boot/efi/EFI
mv refind boot
cd boot
mv refind_x64.efi bootx64.efi
 
exit
umount # everything in /mnt

Reboot. Without ‘‘alt’’ pressed, OS X will boot. With ‘‘alt’’ pressed, you can change your startup partition. To permanently change to another partition, hold ‘‘ctrl’’ while selecting one from this menu.

Post-installation

To make Arch instad of Mac the first entry in rEFInd

In /boot/efi/EFI/boot/refind.conf, set default_selection to 2. Also, you can set timeout to 3.

User

useradd -m -g users -G wheel -s /bin/bash alexx
passwd alexx
pacman -S sudo
visudo  # uncomment the %wheel [...] line

Install the necessary packages

dhcpcd enp1s0f0
pacman -Syyu
pacman -S xorg-server xorg-server-utils xorg-xinit xterm 
pacman -S xf86-input-synaptics xf86-video-intel  # Touchpad and graphics card  
pacman -S lxde 
pacman -S volwheel network-manager-applet ttf-dejavu alsa-utils
## Also, install batterymon-clone from the AUR
systemctl enable NetworkManager
 
pacman -S make firefox 
pacman -S fakeroot binutils  # for AUR's makepkg

Xorg

Make your ‘’’~/.bash_profile’’’ this:

[[ -f ~/.bashrc ]] && . ~/.bashrc
 
if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
  exec startx
  # Could use xinit instead of startx
  #exec xinit -- /usr/bin/X -nolisten tcp vt7
fi

Your ‘’’~/.xinitrc’’’:

volwheel &
batterymon &
(sleep 40 && pkill dropbox && dropboxd) &  # dont start, but restart dropbox by using pkill before.
exec dbus-launch startlxde

Apple keyboard and trackpad

To make F1-F12 keys work permanently without pressing Fn, put this in /etc/modprobe.d/hid_apple.conf:

options hid_apple fnmode=2

(For a temporary change or when it sometimes just doesn’t work after booting, echo 2 > /sys/module/hid_apple/parameters/fnmode)

Create /etc/X11/xorg.conf.d/10-keyboard.conf:

Section "InputClass"
  Identifier "system-keyboard"
  MatchIsKeyboard "on"
  Option "XkbLayout" "de,us"
  Option "XkbModel" "pc104"
  Option "XkbOptions" "grp:caps_toggle"  # This makes Caps Lock toggle between DE and US keyboard layout!

To disable the annoying accidental tap clicks, in /etc/X11/xorg.conf.d/50-synaptics.conf, comment out the three “TapButton” lines:

#      Option "TapButton1" "1"
#      Option "TapButton2" "2"
#      Option "TapButton3" "3"

Best to reboot now and log in as user (starting LXDE).

If umlauts are weird dead keys in xterm (but not in Firefox), re-check your locale.gen and .conf, and generate them, reboot. I did the “turning it off and on again” and it worked then. Weird.

Further info:

  • Check here and here for fancy trackpad finger wipe gestures.
  • Check here for media and hotkeys.

Wireless

Install b43-firmware from the AUR. (Necessary commands: makepkg -s and pacman -U)

Openbox config

In ~/.config/openbox/lxde-rc.xml, add these lines for Ctrl-Alt-T to open a terminal and Ctrl-Alt-F to open a file manager:

#  <keyboard>
#    <chainQuitKey>C-g</chainQuitKey>
    <keybind key="C-A-t">
    <action name="Execute">
    <execute>terminator</execute>
    </action>
    </keybind>
    <keybind key="C-A-f">
      <action name="Execute">
        <execute>pcmanfm</execute>
      </action>
    </keybind>
#    <!-- Keybindings for desktop switching -->
#    <keybind key="C-A-Left">

Install your user software

Install dropbox from the AUR. Set it up. Afterwards, delete ~/.config/autostart/dropbox.desktop (because you already put a delayed start call in your ~/.xinitrc). TODO: This autostart file gets restored automatically. Why?

Now, pacman -S the following packages:

  • arandr
  • auctex
  • cups
  • cups-filters
  • emacs
  • evince
  • flashplugin
  • filezilla
  • gcc
  • gcc-fortran
  • gimp
  • glhack (or AUR’s nethack-x11[-patch] if it tickles your fancy)
  • jre7-openjdk
  • lame
  • leafpad
  • libreoffice
  • nfs-utils
  • openssh
  • r
  • subversion
  • tcl
  • terminator
  • texlive-bin
  • texlive-core
  • texlive-fontsextra
  • texlive-latexextra
  • thunderbird
  • tk
  • unrar
  • unzip
  • wget
  • zip

Install emacs-ess from the AUR.

Configure your software

Your ~/.emacs (this is probably only relevant for me. I saved a shared config file for all my computers on Dropbox):

(load-file "~/Dropbox/config/emacs/dotemacs.el")

Add icons in your Openbox quickstart bar:

  • Firefox
  • Emacs
  • Lxterminal (but remember the shortcut Ctrl-Alt-T)

For thunderbird, you have to create a manual entry (TODO/auto-appeared after a thousand reboots).

Set your email accounts in thunderbird.

Firefox plugins:

  • AdBlock Plus
  • HTTPS Everywhere
  • Reddit Enhancement Suite

For dual monitors, get a display port adapter and start arandr, the GUI for xrandr.

Eduroam in NetworkManager

Following this guide (Use TTLS/PAP): http://www.lrz.de/services/netz/mobil/802_1x/802_1x-linux-ubuntu/

  • General
    • Automatically connect to this thing
  • Wi-Fi
    • SSID: eduroam
    • MTU: automatic
  • Wi-Fi Security
    • Sec: WPA&WPA2 Enterprise
    • Auth: Tunneled TLS
    • Anon: anonymous@mwn.de
    • Cert: /etc/ssl/certs/Deutsche_Telekom_Root_CA_2.pem
    • Inner: PAP
    • User: [me]@campus.lmu.de
    • Enter the password

Because of some bug, you have to enter the password manually every time for now. It’s weird. A solution is described here. Summary: Edit your /etc/NetworkManager/system-connections/eduroam\ TTLS file’s [802-1x] section. Delete the line password-flags=1

#[802-1x]
#eap=ttls;
#identity=user@uni-saarland.de
#ca-cert=/path-to-certificate/telekom.cer
#phase2-auth=mschapv2
password=EnterYoursHere
#system-ca-certs=true

Printing

  • Install cups and hplip (for HP printers)
  • Do systemctl enable cups.service from the console and restart (or do systemctl start cups.service additionally instead).
  • Browse to http://localhost:631/ and add printers manually (enter IP etc.), otherwise you might print to random printers in your network.

Wacom tablet

  • Do: sudo pacman -S xf86-input-wacom
  • Plug in the USB tablet
  • Restart X so it recognizes it
  • Do: xsetwacom --list devices
  • To display all possible options: xsetwacom --get "Wacom Graphire2 4x5 stylus" all - or eraser/cursor instead of stylus
  • Relative cursor position (put these in a shell script):
    • xsetwacom --set "Wacom Graphire2 4x5 stylus" Mode Relative
    • xsetwacom --set "Wacom Graphire2 4x5 eraser" Mode Relative
  • Arch wiki: Wacom, it has info on how to automate that.

For cursor speed see here:

  • xinput list, Write down the IDs of your devices (e.g. 16)
  • xinput watch-props 11, Write down ID of Device Accel Constant Deceleration (e.g. 270)

Then, change deceleration from 1 to 2.5: (for each input device)

  • xinput set-prop 16 270 2.5

Two screens

Install ‘arandr’ and click together a layout. Save the shellscript and put it in ~/bin/2screens.sh or whatever.

Misc things and issues

To disable the trackpad when a mouse is plugged in and avoid accidental weird emacs scrolls / copy-pastes (from here):

SUBSYSTEM=="input", KERNEL=="mouse[0-9]*", ACTION=="add", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/username/.Xauthority", RUN+="/usr/bin/synclient TouchpadOff=1"
SUBSYSTEM=="input", KERNEL=="mouse[0-9]*", ACTION=="remove", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/username/.Xauthority", RUN+="/usr/bin/synclient TouchpadOff=0"

Emacs-color-theme

check this thread

emacs-color-theme requires xorg-fonts-100dpi, which screws up firefox fonts also. Do this to fix:

sudo ln -s /etc/fonts/conf.avail/70-no-bitmaps.conf /etc/fonts/conf.d
## to revert: sudo rm /etc/fonts/conf.d/70-no-bitmaps.conf