Linux on the Macbook Air (2013)

So... i'm now running xfce4 on the Macbook.

First via mint 16, then later i reinstalled xubuntu 14.04.

OSX upgrades

If you have booting via refind working, and then upgrade OSX, it kills refind. Yay! Fortunately it doesn't seem to mess with existing partitions so all your linux stuff should still be there. I found that reinstalling refind from OSX was sufficient to get working again. Just download refind and run the install-refind script from the Terminal (I did this from Recovery mode because I wasn't sure if the warnings about "sip mode" applied to me), then reboot, and you can boot back into linux or OSX as desired.

Webcam

Doesn't work. No driver exists for the 2013 Air, apparently.

Display

Screen hotplugging could be better:

  • DOesn't work at all on thunderbolt (yet... trying things still).

  • Works (sort of) with thunderbolt-to-DCMI adapter

If I have an external monitor plugged in, and use xfce4-display-settings to enable only the external monitor and disable the built-in one, and I unplug the external... the laptop screen does not wake up. I'd love for it to remember my preferred setup and switch on monitor connect/disconnect. Need to research this. Meanwhile I have trained myself to be careful and always switch to laptop screen before unplugging.

Funny: I had some recurring problems with my external Samsung display not working at all, either in OSX or Linux. It turned out to user error kicked off by a rare hardware design fail on Apple's part: The apple-manufactured (not a cheap knockoff) thunderbolt display adapter can be plugged in upside down just as easily as rightside up, and it only works one way. They are usually quite good about that sort of thing. Didn't even occur to me I might be doing it wrong. Duh.

Monitor black after suspend/resume

If I close the lid, the internal display goes black as expected; but when I resume, it wouldn't light up again. Tried various workarounds from the 'net. Eventually got too frustrated since nothing seemed to quite stick.

Uninstalled light-locker and installed xscreensaver instead;

then to get it running automatically on suspend/resume I followed http://askubuntu.com/questions/20585/how-to-lock-xscreensaver-on-suspend which works for manual suspend but not on lid close.

Tried hacking /etc/systemd/logind.conf as per https://bugs.launchpad.net/ubuntu/+source/xfce4-power-manager/+bug/1349056 ... no joy.

... aha! reverse that: HandleLidSwitch=suspend LidSwitchIgnoreInhibited=yes

yay!

Chrome display artifacts

Had problems with the Chromium browser not repainting properly when switching to the desktop it's on ... things from other desktops would be shown with rectangular areas of Chrome content overlaid. To fix it, turned off compositing (settings -> window manager tweaks -> compositing)

Kernel

In a (pointless) effort to get thunderbolt display hotplug, I upgraded to the "LTS Hardware Enablement Stack". See:

https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes#LTS_Hardware_Enablement_Stack

That done, I had to get ReFIND to boot it by default (a later ubuntu system update installed another 3.13.something kernel and refind started using it by default). To fix:

edit /boot/efi/EFI/boot/refind.conf and change the default_selection to:

default_selection "vmlinuz-3.19"

Thunderbolt display

I now have a LG Electronics 34" monitor at work that Works fine out of the box at 3440x1440.... except you can't hotplug it. If I plug in, I have to reboot. Ouch. Currently trying kernel upgrade via the LTS Hardware Enablement Stack: https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes#LTS_Hardware_Enablement_Stack ... no joy, linux 3.19 apparently includes the thunderbolt hotplug patches but it apparently doesn't support hotplug for displays.

I added 'thunderbolt' to /etc/modules but that didn't seem to help either.

WATCH OUT: thunderbolt hotplug support may be causing battery eating? If so, try adding acpi_osi= to kernel boot params as per https://bbs.archlinux.org/viewtopic.php?pid=1530283#p1530283

Display resolution on Samsung

UNRESOLVED: Max resolution on Xubuntu 14.04 is poor compared to Mint 16. For some reason Mint 16 XFCE out of the box gave me the full 2560x1440 whereas on xubuntu 14.04 I could only get 1920x1200 (or 1920x1080 which is correctly proportioned on this screen).

Apparently I am using the i915-3.16-3.13-dkms driver via the xerver-xorg-video-intel driver, I think. package: xserver-xorg-video-intel Version: 2:2.99.910-0ubuntu1.6 Config-Version: 2:2.99.910-0ubuntu1.6

Confirmed that Mint 17 XFCE has same problem (from live usb drive). Found this thread: http://ubuntuforums.org/showthread.php?t=2218618 Filed a bug upstream too.

Tried: - boot params i195.i915_enable_rc6=1 i195.i195_enable_fbc=1 ... these are just "unknown parameter" "ignored" according to /var/log/kern.log ... removed, made no difference. - added boot param "nomodeset" - this just totally breaks external display, it's not detected at all - removed boot param "i915.lvds_downclock=1" ... no help, I put it back.

Touchpad:

Internal: Works pretty much OK.

I've had problems with it triggering too easily while typing though, even though I clicked the usual "Disable touchpad while typing" option. The result is that I'll be typing along and then suddenly some menu has popped open and the keys I've typed have selected something and I'm off into crazy-land. Currently trying this: http://askubuntu.com/a/300879 ... seems to help, but does not stick; I found that synclient PalmMinZ=255 does the same thing. Also seems to help:

killall syndaemon
syndaemon -i 1 -KRd

So I have all this in a session startup script. Fingers crossed.

External Magic Trackpad: I gave up on it. It worked OK but was very finicky; trying to dial down the sensitivity via Synclient, I never did figure out how to do that for ONLY the external trackpad; my settings killed the internal one.

I did have to enable 2-finger scroll in the SEttings -> Mouse and Touchpad app. Disabled single-finger tap-to-click, it drives me insane. Without buttons, I would really like a binding similar to OSX's Shift-Click to trigger right-click, and something similar for middle-click but haven't figured out how yet.

I had settled in to using two-finger tap for right click and three-finger tap for middle click, and disabling one-finger tap.

I'm also setting any click to be left click. Relevant settings:

    EmulateMidButtonTime    = 0
    RTCornerButton          = 0
    RBCornerButton          = 0
    LTCornerButton          = 0
    LBCornerButton          = 0
    TapButton1              = 0
    TapButton2              = 3
    TapButton3              = 2
    ClickFinger1            = 1
    ClickFinger2            = 1
    ClickFinger3            = 1
    ClickPad                = 1
    RightButtonAreaLeft     = 0
    RightButtonAreaRight    = 0
    RightButtonAreaTop      = 0
    RightButtonAreaBottom   = 0
    MiddleButtonAreaLeft    = 0
    MiddleButtonAreaRight   = 0
    MiddleButtonAreaTop     = 0
    MiddleButtonAreaBottom  = 0

Synaptics configuration seems a bit flakey. I've put all my settings in /etc/X11/xorg.conf.d/60-synaptics.conf ... but if I run "synclient -l" after starting, some of the settings don't take (confirmed by the external touchpad not behaving as configured). So I have to re-apply those settings by re-running synclient ... which is annoying as there's no way to specify which device, so I guess it does all devices.

Update: I found the touchpad was causing me repetitive stress. Clicking was too hard. I'm currently using an Evoluent vertical mouse and finding it very comfy.

Power / Battery

I followed some instructions on https://help.ubuntu.com/community/MacBookAir6-2/Saucy to tweak things for better battery life. I currently can do at least 5 solid hours of work, sometimes more. It got better with recent kernel upgrades too.

I did tweak /etc/default/tlp a bit ... forget what exactly. CPU governors?

powertop tunables - BEFORE:

>> Bad           Wireless Power Saving for interface wlan0                      
   Bad           NMI watchdog should be turned off
   Bad           VM writeback timeout
   Bad           Enable SATA link power Managmenet for host0
   Bad           Enable Audio codec power management
   Bad           Autosuspend for USB device Bluetooth USB Host Controller [Apple
   Bad           Autosuspend for USB device Card Reader [Apple]
   Bad           Autosuspend for USB device Apple Internal Keyboard / Trackpad [
   Bad           Autosuspend for USB device External HDD     [Western Digital ]
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP SMBus
   Bad           Runtime PM for PCI Device Intel Corporation Haswell-ULT DRAM Co
   Bad           Runtime PM for PCI Device Intel Corporation Haswell-ULT HD Audi
   Bad           Runtime PM for PCI Device Intel Corporation Haswell-ULT Integra
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP USB x
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP PCI E
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP PCI E
   Bad           Runtime PM for PCI Device Marvell Technology Group Ltd. 88SS918
   Bad           Runtime PM for PCI Device Broadcom Corporation BCM4360 802.11ac
   Bad           Runtime PM for PCI Device Broadcom Corporation Device 1570
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP LPC C
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP PCI E
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP HD Au
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP PCI E
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP HECI
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP PCI E
   Good          Bluetooth device interface status
   Good          Autosuspend for USB device xHCI Host Controller [usb1]
   Good          Autosuspend for USB device xHCI Host Controller [usb2]
   Good          Autosuspend for USB device BRCM20702 Hub [Apple Inc.]
   Good          Wake-on-lan status for device wlan0
   Good          Using 'ondemand' cpufreq governor

powertop tunables - AFTER:

>> Bad           Wireless Power Saving for interface wlan0                      
   Bad           Enable Audio codec power management
   Bad           Enable SATA link power Managmenet for host2
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP SMBus
   Bad           Runtime PM for PCI Device Marvell Technology Group Ltd. 88SS918
   Bad           Runtime PM for PCI Device Broadcom Corporation BCM4360 802.11ac
   Bad           Runtime PM for PCI Device Broadcom Corporation Device 1570
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP LPC C
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP PCI E
   Bad           Runtime PM for PCI Device Intel Corporation Haswell-ULT DRAM Co
   Bad           Runtime PM for PCI Device Intel Corporation Haswell-ULT Integra
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP USB x
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP HD Au
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP HECI
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP PCI E
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP PCI E
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP PCI E
   Bad           Runtime PM for PCI Device Intel Corporation Lynx Point-LP PCI E
   Bad           Runtime PM for PCI Device Intel Corporation Haswell-ULT HD Audi
   Good          VM writeback timeout
   Good          NMI watchdog should be turned off
   Good          Bluetooth device interface status
   Good          Autosuspend for USB device Bluetooth USB Host Controller [Apple
   Good          Autosuspend for USB device xHCI Host Controller [usb1]
   Good          Autosuspend for USB device xHCI Host Controller [usb2]
   Good          Autosuspend for USB device Card Reader [Apple]
   Good          Autosuspend for USB device Apple Internal Keyboard / Trackpad [
   Good          Autosuspend for USB device BRCM20702 Hub [Apple Inc.]
   Good          Autosuspend for USB device External HDD     [Western Digital ]
   Good          Wake-on-lan status for device wlan0
   Good          Using 'ondemand' cpufreq governor

Suspend/Resume and All About Brightness

I had the issue where backlight goes black after resume (system seems hung but isn't, you just can't see anything).

I've worked around this (see below) but neanwhile I learned of necessity to do two ridiculous things with no display:

  • enter my password, and/or recognize when the login dialog hasn't got focus for some odd reason so I need to hit tab before the password

  • open a terminal (ctrl-t) and type xbacklight -set 75

** TL;DR

The mba6x_bl module fixes the backlight going black after resume, but breaks the display brightness keys.

This seems like a workable tradeoff, I have workarounds for the keybindings.

The place to start is: https://help.ubuntu.com/community/MacBookAir6-2/Trusty

"power manager not authorized"

I occasionally get a "power manager not authorized" alert after resume. Testing possible solution from https://bugs.launchpad.net/ubuntu/+source/xfce4-power-manager/+bug/1319598/comments/17 https://bugs.launchpad.net/ubuntu/+source/xfce4-power-manager/+bug/1319598/comments/17 ... this hasn't happened in a while, don't honestly know what fixed it.

Display backlight brightness key

This didn't work on mint 16 running xfce4, nor xubuntu ... it worked under Cinnamon.

My original workaround was via xbindkeys and xbacklight -inc 10 for brighter, and xbacklight -dec 10 for darker.

Then the keys worked out of the box again when I installed xubuntu 14.04, then some system update broke that at some point, and instead, a notification widget is shown as if the brightness were changing, but it doesn't actually change. I would override the keybindings to call my scripts instead, but it seems that you can't override the brightness keys. xbacklight and my wrapper scripts still work, but the keybindings get ignored. You can set something in xbindkeys-config but it doesn't actually override the key.

As of kernel 3.19.0-26-generic (from the Hardware Enablement Stack... see https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes#LTS_Hardware_Enablement_Stack) if I remove the mba6x_bl module, the keys work out of the box, but then I'm back to having the screen come up black after resume and at login :(

It seems to be that the keys are hardwired to control the intel backlight interface, not the mba6 one. These can be seen like so:

$ for interface in /sys/class/backlight/*; do echo -e "\n $interface"; cat $interface/{brightness,max_brightness,actual_brightness}; done

 /sys/class/backlight/intel_backlight
2777
2777
2777

 /sys/class/backlight/mba6x_backlight
191
255
191

Note in this output that the intel interface thinks the backlight is at 100% but the mba6x_backlight interface thinks it's at 75%. I confirmed that the brightness keys affect the intel_backlight output but not the mba6x_backlight output; and if i use xbacklight, it's vice-versa.

The result is that the screen brightness keys do nothing except update the widget that makes it look like it's doing something, and they update intel_backlight, but nothing happens until you go all the way down to zero - at which point the display abruptly shuts off completely and then DOESN'T COME BACK ON if you press the up key again. You gotta blindly find a terminal and run "xbacklight -set 75" or similar to get it back on.

My current backlight keys config / workaround

This combination gives me: - login window always comes up visible - backlight comes back on after suspend - backlight works via xbacklight scripts - i have scripts bound to alternate keys - avoid touching the "correct" screen brightness keys

Steps to get there: - install the "hardware enablement stack" to get 3.19 - might be not necessary but works... https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes#LTS_Hardware_Enablement_Stack - sudo dpkg -i mba6xbl-dkms_1.0.0_all.deb - I found it at https://github.com/patjak/mba6x_bl - Use these kernel options: video.use_native_backlight=1 acpi_osi= acpi_backlight=vendor - I boot with reFind so i did that by editing /boot/refind_linux.conf and changing the default opions to look like this:

"Boot using standard options" "root=<MY ROOT UUID put yours here> $vt_handoff pcie_aspm=force i915.lvds_downclock=1 video.use_native_backlight=1 acpi_osi= acpi_backlight=vendor"

Keyboard backlight brightness key

Didn't work either ... it used to work under Cinnamon. I worked around this with scripting: I downloaded, hacked slightly, and wrapped this script: http://keramida.wordpress.com/2013/03/28/controlling-the-keyboard-backlight-from-cli/

TODO: I don't have an "insert" key. I miss "shift-insert" to paste the X clipboard.

I use xbindkeys-config to bind the keyboard brightness keys to my scripts. Unlike the display brightness keys, this actually works.

Other Keybindings

Internal: Two problems. The ~/ key was putting out < instead. And I wanted to globally switch the Command and Alt keys. Accomplished this via xmodmap (I realize people now use xkb or whatever it's called, but this was what I figured out.)

TODO: move xmodmap config into my X settings.

OR... TODO: I recall running across some other apple-specific ways to do things but can't find now.

Printers

Brother MFC-J835DW: Just Worked via the settings -> printers tool. I connected via dnssd and chose the suggested CUPS driver.

Not under 14.04 though, hmm. Went to http://support.brother.com/g/b/downloadend.aspx?c=us&lang=en&prod=mfcj410w_us&os=128&dlid=dlf006893_000&flang=4&type3=625 unzipped and ran the script, gave it full printer name (MFC-J835DW) and it downloaded and installed drivers.

Brother MFC-9970CDN: Just Worked via settings -> printers. I found it in the list of networked printers and accepted all the suggested defaults (generic postscript level 3).

Brother MFC-9460CDN printing via wifi: I wasn't able to get this to work via the usual print config settings app or the CUPS web interface. I can find the printer and configure it seemingly, and test pages claim to finish processing, but the printer never actually prints. Nothing informative in any logs I could find.

Instead: go to http://welcome.solutions.brother.com/bsc/public/us/us_ot/en/dlf/dlf/000000/006800/dlf006893.html?reg=us&c=us_ot&lang=en&prod=mfc9460cdn_all&type2=91&os=128&flang=4&dlid=dlf006893 download the gzipped file, unzip it and run it. "Machine name" is "MFC-9460CDN".
On Mint, this downloads a TON of extra Ubuntu packages, like 255, but eventually it worked.

For the printer's address, when prompted I entered ipp://[ ip address here]

Scanning ... no joy.

Virtualbox

was hanging on shutdown if I didn't remember to stop it manually. I tried http://lifeofageekadmin.com/how-to-set-your-virtualbox-vm-to-automatically-startup/ and all the fixes mentioned in comments, but no joy. Finally hacked /etc/init.d/rc.local (NOTE must add a symlink at /etc/rc6.d/k00local) to have a stop command that kills my one VM:

 do_stop() {

        if [ -d /x/y/z ]; then
                cd /x/y/z
                [ "$VERBOSE" != no ] && log_begin_msg "Shutting down Devolate..."
                sudo -u pw vagrant halt
                ES=$?
                cd - > /dev/null 2>&1 
                [ "$VERBOSE" != no ] && log_end_msg $ES
                return $ES
        fi
    }
  }

And then linked it to kill early in the shutdown sequence:

  cd /etc/rc6.d
  sudo ln -s ../init.d/rc.local K05local

I forget if it was already linked or not.)

Terminal

I've gone back to Roxterm because it does everything I want:

has Search. (To bind this to Ctrl-Shift-S, I went to Configuration Manager, Shortcuts, toggled Enable Editing, then used the right-click menu d to navigate to Search -> Find and hit Ctrl-Shift-S.) ... BUT not safe to use: there is a bug that causes it to crash :-p http://sourceforge.net/p/roxterm/bugs/99/

has hooks for tweaking profile via command line (using dbus), which I use in my sshwrap hack... I missed that one.

Power button

Pushing it was just shutting down without prompting. I like the usual choices there (log out, restart, shutdown, sleep). Solution: sudo apt-get install xfce4-power-manager

CPU Turbo Boost

I downloaded i7z_64bit and found that no matter what, CPU was not going above 1.7GHz; it should have turbo into the 3.something range.

Tried: - Boot with acpi=off ... this kills all power management stuff, no turboo, but i get a fixed freq of 2.2GHz... pystones went up a bit

  • Install msr module: sudo apt-get install linux-tools-common linux-tools-3.11.0-12-generic

    • and edit /etc/modules and add "msr"
  • Don't start ondemand governor:

    $ for f in sudo find /etc -name "S*ondemand"; do sudo mv -i $f echo $f | sed -e s/S99/K99/g; done

TODO - try new kernel, then try "intel_pstate=enabled" kernel param. See http://www.webupd8.org/2014/04/prevent-your-laptop-from-overheating.html

External Keyboard

I'm using a Kinesis Freestyle 2 (mac version). Still a work-in-progress:

  • there's no Insert key, so I don't have shift-insert! Wah!

  • I need to figure out how to get more keys recognized; eg. volume up/down/mute don't send anything at all according to xev.

Superdrive (USB cd/dvd drive)

Does nothing out of the box.

sudo apt-get install sg3-utils
sg_raw /dev/sr0 ea 00 00 00 00 00 01  # wakeup command I googled somewhere

cdcd works enough to recognize the disk but won't make it spin or eject:

   sudo apt-get install cdcd
   cdcd info
    Album name:     The Woods
    Album artist:   Sleater-Kinney
    Total tracks:   10      Disc length:    48:10
    Stopped

But! Thunar (the xfce file manager) recognizes it. The disk shows up on my desktop as "audio disk" - I can open it and it lists 10 wav files as the contents. And I can eject. Yay.

cdparanoia works. Does DVD playing work? Yep... I popped in a DVD and tried mplayer dvd://1 -dvd-device /dev/sr0 and it worked right off the bat. (With subtitles on by default... I need to read the mplayer man page...)

DVD ripping: After wakeup, AcidRip just works. (Check the option to use separate file for subtitles, otherwise acidrip always includes subtitles even if you turn them off - duh.)

Android sync

I don't have a good setup for this yet. MTP doesn't work out of the box. Grr.

Instead I run an ssh server on the droid, and use rsync to copy data.

For music, I use banshee - having a bitch of a time getting it to sync with the Android. MTP broken?

Packages installed specially:

for my keykey hack:
wmiface http://kde-apps.org/content/show.php?content=40425
then xbindkeys-config, test all, apply

display driver:
https://01.org/linuxgraphics/downloads/2014/intelr-graphics-installer-1.0.6-linux

hacking & work stuff:

vagrant  https://www.vagrantup.com/downloads.html
virtualbox https://www.virtualbox.org/wiki/Linux_Downloads
hipchat - add the ppm per https:/u  /www.hipchat.com/downloads#linux-install
# go (needed by hub) https://golang.org/dl/
# ... actually no, hub comes precompiled

hub https://github.com/github/hub

Python packages:
       flake8
       nose
       pip
       virtualenv
       rope
       ropemacs
       ropemode
       pymacs