How to setup Ubuntu on a MacBook Pro
Tags: macbookpro, ubuntu, linux, tutorial
Published: 2018-01-23 14:40:50

---
title: How to setup Ubuntu on a MacBook Pro
published: true
tags: ["macbook pro", "ubuntu", "linux", "tutorial"]
canonical_url: https://lobotuerto.com/blog/how-to-setup-ubuntu-on-a-macbook-pro/
cover_image: https://thepracticaldev.s3.amazonaws.com/i/r1f79hlnqqy36q85o0f1.jpg
---

_These instructions were tested on a MacBook Pro Mid 2014.  
Should —probably— work just fine on other MacBooks._

* * *

If you install Ubuntu on a MacBook, you’ll soon find a small —but highly irritating— set of behaviours:

- The Alt and Cmd keys are swapped out (using a PC keyboard as a reference).
- The _function keys_ are swapped out with the _multimedia keys._
- Cannot easily _copy & paste_ on the CLI with the laptop’s keyboard.
- The trackpad behaves erratically.
- You can hardly read anything on the screen or…
- Maybe the UI size is too big and you’d want to adjust it to your liking.

If this sounds like your kind of problems, then keep reading, solutions are ahead.  
_Right now, the only issue without a solution is the integrated webcam. **It does not work.** _

# Keyboard issues

## Swap Cmd and Alt keys

If you’d like your Alt key where it usually is on every PC —except Macs. With immediate effect, but temporary:

```
echo 1 | sudo tee /sys/module/hid_apple/parameters/swap_opt_cmd
```

Make it permanent:

```
echo options hid_apple swap_opt_cmd=1 | sudo tee -a /etc/modprobe.d/hid_apple.conf
sudo update-initramfs -u -k all
```

## Enable function keys

This will make your function keys available by default. To use your multimedia keys, you’ll now need to hold the **fn** key while pressing a multimedia one.

With immediate effect, but temporary:

```
echo 2 | sudo tee /sys/module/hid_apple/parameters/fnmode
```

This change is not permanent. To make it so:

```
echo options hid_apple fnmode=2 | sudo tee -a /etc/modprobe.d/hid_apple.conf
sudo update-initramfs -u -k all
```

## Paste with a single key

If you’ll be using the _reduced_ laptop keyboard, it’s going to be tough to always use the mouse for copy & pasting.

What about using the **Right Super** key (the one labeled as _Alt_ if you swapped the _Cmd_ and _Alt_ keys above) for pasting?

```
sudo apt install xkbset

echo "" >> ~/.bashrc
echo "xmodmap -e \"keycode 134 = Pointer_Button2\"; xkbset m" >> ~/.bashrc
```

It works just like when you highlight some text with the mouse then click the **middle button** to paste it somewhere else.

_Whenever you highlight text with your mouse in Ubuntu, it is copied to a special buffer that you can paste from clicking the mouse’s mid button._

_Pasting in the CLI is usually done with **Shift + Ins** , good luck finding the Insert key._

# Trackpad issues

If your mouse’s cursor is jumpy, or you do have general problems using the Mac’s trackpad, then you should install `libinput`:

```
sudo apt install xserver-xorg-input-libinput
```

To customize the trackpad behavior, you need to modify the `/usr/share/X11/xorg.conf.d/60-libinput.conf` file.

Some of the changes above require a restart.

# High DPI displays

## Vanilla Ubuntu

To adjust the text size (font size) in general, with immediate effect, try:

```
gsettings set org.gnome.desktop.interface text-scaling-factor 1.65
```

I think it’s better to learn how to do this kind of stuff from the command line (CLI), but if you want to take a look at all the available options, you’ll need `dconf-editor`:

```
sudo apt install dconf-editor
```

_You can check out on the value you just changed by executing `dconf-editor` and browsing to the location we used above: **org -\> gnome -\> desktop -\> interface.** _

## i3 Ubuntu

Unfortunately, **i3** does not use the info set in`org.gnome.desktop.interface text-scaling-factor`.

So, another way to adjust the display is to change the screen mode (resolution), this one works well:

```
xrandr --output eDP-1 --mode 1680x1050
```

What we did was to downscale the resolution from 2560x1600 to 1680x1050.

 TIP ~ Back to login screen 

On i3 you can close your session with: **Shift + Super + E.**

_**Super** is the **Windows** key._

If you, somehow cannot press that combination, you can use (with caution), the next command:

```
kill -9 -1
```

<!-- TODO: concentrar esta info en un post de swiss army o cheat sheet de "daily ubuntu" [new series?] -->

This will terminate all the user processes, and get you back to the login screen.

- **DO NOT** execute it with `sudo`.
- **DO NOT** execute it if you have unsaved data.

<!-- TODO: poner enlace al nuevo post sobre DPI en ubuntu -->