## Wednesday, January 29, 2014

### On Plural-Data Prescriptivism in Academia

I really have no problems with people using data in the plural. Rather, I'm annoyed at the small and sometimes vocal minority within the statistics community (and in the wider academic community) which likes to proselytise the plural-data rule as if there was some sort of authority to it. Unfortunately, that's not how language works; language is democratic, and its 'rules' naturally evolve through the usage of its speakers. Excepting a dead civilisation, mediæval European scholars, and some modern-day scholars, hardly anyone uses 'data' as a plural noun any more. The fact that some scientists or statisticians would claim that there is a 'correct' way of using this word, then, strikes me as rather contrary to the goal of science itself -- namely, to describe the mechanisms underlying a system by examining it empirically.

## Wednesday, January 8, 2014

### Arch + XMonad / GNOME on MacBook Pro Retina 11,1 (13-inch, late 2013)

For the past few months, I've tried running OS X as my main OS on my MacBook Pro Retina (late 2013). I eventually got tired of it, so a week ago I started trying to figure out how to dual boot Arch on this machine. This is a log of the steps that had to go through. (Before doing this, I reset OS X via the recovery partition, so this is a clean install.) The following additional pages may be helpful as reference:

I'm assuming that the reader has some basic level of familiarity with Linux and can understand most of what I'm doing (or look it up if need be). If anyone has any updates or helpful info, feel free to email me and/or comment below, and I will update the guide accordingly.

### Boot disk

dd if=arch.iso of=/dev/sdX
to create the boot disk.

We will use rEFInd because it seems slightly easier than hooking up GRUB to EFI. In OS X, download the rEFInd package and run
sudo ./install.sh --alldrivers
Edit /EFI/refind/refind.conf and enable the scan_all_linux_kernels option. (I also enabled textonly mode because I thought the GUI looked tacky.) In the folder /EFI/refind/drivers_x64, remove all the drivers except the one for EXT4. (Not sure if the last step is necessary -- can someone confirm?)

### Partitioning, Part 1

While still in OS X, use the partition manager to resize your OS X partition. I left it with 50 GB, but this is up to personal preference. Note that OS X actually has 3 partitions (EFI boot partition, main partition, recovery partition), but it only shows you one of them.

### Internet

Boot into your Arch live USB (rEFInd should be able to detect it automatically). You need an internet connection to install the base system. I used USB tethering via an Android phone, but other options may work as well.

### Partitioning, Part 2

Use cgdisk /dev/sda to set up / on /dev/sda4 and /home on /dev/sda5. Then run
mkfs.ext4 /dev/sda4
mkfs.ext4 /dev/sda5
mount /dev/sda4 /mnt
mkdir /mnt/home && mount /dev/sda5 /mnt/home

to create new EXT4 file systems on those partitions and mount them.

### Base System / Partitions, Part 3

Run the following to set up the base system and fstab:
pacstrap /mnt base base-devel
genfstab /mnt >> /mnt/etc/fstab

At this step we have a basic working Linux system that you can chroot or reboot into:
arch-chroot /mnt /bin/bash


### SSD Performance issues

We should edit /etc/fstab to improve SSD performance:
/dev/sda4   /       ext4    defaults,noatime,discard    0 1
/dev/sda5   /home   ext4    defaults,noatime,discard    0 2

The default boot options may cause the SSD to hang. Add the following line to /boot/refind_linux.conf to prevent this:
"Default" "ro root=/dev/sda4 libata.force=noncq"

### Keyboard / Locale / Time

echo "somehostname" > /etc/hostname

# set up keyboard layout and system locale
echo "KEYMAP=dvorak" > /etc/vconsole.conf
vi /etc/locale.gen # uncomment what you want
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf

# set local time and set hardware clock to UTC
ln -s /usr/share/zoneinfo/US/Pacific /etc/localtime
hwclock --systohc --utc


### Users

# set root password
passwd

visudo # uncomment wheel

One last thing -- we should set up wifi before rebooting and logging in to the new account.

### Yaourt, Wifi

Follow the instructions here to get yaourt. Then use it to install broadcom-wl from the AUR to get wifi drivers:
yaourt -S broadcom-wl

I like to manage my connection with wicd so I'll get that as well:
pacman -S wicd
systemctl enable wicd.service

Now we can reboot and start playing around with the system!

Normally I would forgo GNOME, but they currently have (as far as I know) the best solution to solving the high-DPI scaling issue. Grab the following packages:
pacman -S xorg-server xorg-xinit xorg-server-utils xf86-video-intel xf86-input-synaptics \
gnome-session gnome-settings-daemon

Then follow the instructions from my previous post to make XMonad and GNOME play nicely with each other.

The above steps will get a minimal working setup on your Retina Macbook Pro. However, there are still a lot of useful things you could configure to make your life easier:

#### Firefox

Change layout.css.devPixelsPerPx to 2 to make it scale everything up for the retina display.

#### Missing Cursor

Try running
gsettings set org.gnome.settings-daemon.plugins.cursor active false


#### USB Automounting

udiskie is a simple daemon to automount disks with very few dependencies, which is great for a minimal setup.

#### Fonts

OS X ships with some great built-in fonts. I strongly recommend grabbing their fonts from these directories on your OS X install and copying them over to Linux.

## Tuesday, January 7, 2014

### The issue

Currently most Linux desktop environments work rather poorly with high-density displays, and require a lot of manual tweaking. Recently, GNOME 3 added support for high-density displays, so the UI should automatically rescale itself properly for GNOME versions 3.10 and higher. Unfortunately, there's one slight issue: If you connect an external monitor, the text and icons are massive. This is because (as far as I know) GTK, X, and much of the substrata of renderers underlying the GUI only support a global DPI or scale setting for all monitors.

### Workaround

However, there is (sort of) a workaround. We can manually rescale so that the the external monitor is correct, but the retina monitor has small text. (Presumably if you are using an external monitor, then your laptop monitor is not your main work monitor.) In this patch, we see that GNOME rescales windows based on the parameter scaling-factor in schema org.gnome.desktop.interface. Thus, all we have to do to manually set the scale factor is to run
gsettings set org.gnome.desktop.interface scaling-factor X

where X is 1 or 2, depending on how we want pixels to be normal-sized or enlarged. (If X is 0, then GNOME decides for you, but this may or may not be what you want.) For expedience, you can attach a hotkey to these commands, or you can detect xrandr events and rescale automatically.

### Required packages

It turns out that only a very minimal set of packages need to be installed for this to work -- gnome-session and gnome-settings-daemon, at least version 3.10 or higher. Because of the sparse requirements, this can be adapted to work for all GTK applications in lightweight desktop environments / window managers (e.g. XMonad or awesome) so long as you start them via a minimal GNOME session. I also strongly recommend building xmonad-darcs and xmonad-contrib-darcs from the AUR because of a bug (see edit below).

### Minimal .xinitrc + XMonad + GNOME example

A minimal way to get the above method working involves creating the following files:
~/.local/share/applications/xmonad.desktop:
[Desktop Entry]
Type=Application
NoDisplay=true
X-GNOME-Autostart-Phase=WindowManager
X-GNOME-Provides=windowmanager


Make sure you use gnomeConfig in your xmonad.hs. Then end your ~/.xinitrc with
exec gnome-session --session=xmonad

This will execute a minimal GNOME session instance which only runs gnome-settings-daemon, xmonad, and almost nothing else.
Edit (2014-07-16): With the latest version of D-Bus and with XMonad 0.11, gnomeConfig from XMonad.Config.Gnome doesn't properly register XMonad to GNOME, so you'll see a GNOME error dialog upon starting your XMonad-Gnome session. This has been fixed in XMonad-Contrib 0.12 from the AUR.