In Search of an Open macOS

It’s been a while since I took a deep dive into a Linux distro since switching from Windows to a Mac several years ago. Nightmares of missing drivers and endless configuration drew me away from exploring any further. Luckily, OSX/macOS’s user-friendly and Unix-like environment was enough to quell the hacker dreams I had as a budding developer. After four years, I’ve since perfected my development environment on my Mac with my zsh, tmux, and a slew of text editors fine-tuned ad nauseam to my liking. Since reaching “developer nirvana” and seeing my productivity peak, I haven’t found a compelling reason to venture out to Linux or, really, to any other OS for that matter.

However, lately I’ve been hankering to explore free and open-source alternatives to the Apple ecosystem I’ve willingly locked myself into. Although I can’t deny the productivity gains from great suite of apps available on macOS, I feel like I’m losing control of my already eroding personal data in this day and age. As a result, I decided to experiment with one of the most popular Linux distributions similar to macOS: Elementary OS.

First off, Elementary is a beautiful OS that clearly takes some design cues from macOS. Out of the box, the installation and desktop experience is miles ahead of any other Linux distributions I’ve tried. However, as macOS-like as it tries to be, I still found several friction points that prevented me from transitioning over smoothly as a Mac user.

Below are some of the steps I took to turn my regular MacBook into a dual booted machine with an Elementary OS install with the most Mac-like settings. This post is by no means exhaustive, but it covers steps that I could not find in other guides.

I would recommend you use this guide as a supplement to the countless Elementary OS install tutorials that are out there. This article will only guide you through specific steps for setting up a Macbook to play nicely with Elementary.

With that said, enjoy!

Creating the Dual Boot Setup

Before you begin, you will need to reboot your machine into recovery mode in order to disable the System Integrity Protection (SIP) flag via csrutil disable in the terminal. After you boot the machine with this setting off, it will allow you to install the rEFInd boot loader, which is required to dual boot your machine.

When I attempted this step, I found that I could not install rEFInd unless I manually mounted the EFI partition first via sudo diskutil mountDisk /dev/disk0s1 (and of course replace /dev/disk0s1 with the correct disk identifier on your machine).

Replacing Spotlight/Alfred

I’m a huge fan of Alfred on macOS, and the first thing I noticed with a fresh Elementary install was that Command+Space wasn’t bound to anything useful. Luckily, there is a project called Albert (see the similarities?) that has the core features you would expect from a quick launcher.

Install via apt-get, add it to your startup applications in System Settings > Applications > Start, and in Albert’s preferences, set the keyboard shortcut to Super+Space (Command+Space).

Enabling Mac-like Keyboard Bindings

This was the most difficult part for me, as I couldn’t find any definitive resources online regarding this crucial step in closing the loop on the Mac-like experience.

 

Command Key Aliases

Maybe other Linux users prefer sticking with Control+V for Paste, but I find it much more comfortable to use the command key instead. One would naively think swapping Command and Control through xkb would be enough as I have, but there are unfortunately more nuances to it.

Although Command and Control are switched for clipboard operations and other shortcuts, we still need Control to be mapped to the physical key for the terminal, such as Control+C for exiting commands. Another reason for this is for tmux. I like most others have my tmux prefix key mapped to Control+A, which is rendered useless when the keys are swapped.

Therefore, the current solution which was worked well for me is to leave Control and Command as-is and use the Autokey app to create keyboard shortcut aliases for common operations.

One StackOverflow answer hit the mark but didn’t provide complete details. So here is the complete solution that I created:

Run these commands to unbind the defaults that will coincide with our keybindings: repo here.

  1. Install Autokey with `sudo apt-get install autokey-gtk`
  2. Open Autokey, set it as a startup application either through Autokey’s settings or through Elementary OS’s system preferences
  3. Create a folder inside Autokey, which will map to a directory in your system. I made mine in ~/.autokey
  4. Clone this repository into that folder: https://github.com/danyim/elementary-macos

Also it may help to take a look at the default keybindings with this command: gsettings list-recursively | grep -i ".keybindings". Specifically, take a glance at the defaults set for `org.pantheon.desktop.gala` and `org.gnome.desktop.wm.keybindings` bindings. If you find something you don’t like, you can change the value through the terminal’s gsettings or by using the GUI equivalent dconf-editor.

The gsettings commands take the following format:

gsettings set [folder] [command] [value]

Unsetting a command, for example: gsettings set org.pantheon.desktop.gala.keybindings zoom-in []

Setting a command:

gsettings set org.pantheon.desktop.gala.keybindings zoom-in ["'<Super>+P'"]

Mapping the Tilde Key

Also, the tilde/grave key wasn’t working out of the box, so I had to add the following line in /usr/share/X11/xkb/symbols

// Find this line
key { [ less, greater, bar, brokenbar ] };
// Add this beneath it
key { [ grave, asciitilde, grave, asciitilde ] };

After that, clear the cache sudo rm -rf /var/lib/xkb/* and reboot.

Replacing Default Apps

File Explorer

The default File Explorer looks great, but it is very dissimilar to what I’m used to with Finder. A great alternative File Explorer I found is Nemo. It won’t work perfectly out of the box, however.

Run the following to remove the window on your desktop:

gsettings set org.nemo.desktop show-desktop-icons false

Edit your nemo*.desktop files in /usr/share/applications/ and change the Exec field to include --no-desktop, i.e. Exec=nemo --no-desktop

Go into System Settings > Applications and set your default file explorer to Nemo. In my case, I saw two “Files” in the dropdown after I had installed Nemo, so I assumed Nemo was the second.

Terminal

Again, nothing too bad to say about the default Elementary terminal, but I wanted something more customizable a la iTerm2, so I opted to switch my terminal to the GNOME Terminal. This was straightforward for the most part.

Browser

Install Brave, a privacy-focused browser. Follow their instructions here; however, you’ll need to run this line instead of what they provided:

curl https://s3-us-west-2.amazonaws.com/brave-apt/keys.asc
sudo apt-key add - echo "deb [arch=amd64] https://s3-us-west-2.amazonaws.com/brave-apt xenial main"
sudo tee -a /etc/apt/sources.list.d/brave-xenial.list

Improving the Interface: the macOS Look and Feel

There are many different theming applications and plugins to choose from that will help make your Elementary OS feel like a Mac. I haven’t explored those options too deeply yet (I’ll update this post when I do). What I’ve done for now is install Elementary Tweaks and replaced the GTK+ theme with a theme called OS-X Buttons. This simple change will give you a very convincing title bar with the three buttons on the top left that we all know and have grown to love.

Adding an Icon Set

Check out this project for a great set of macOS-like icons: https://github.com/keeferrourke/la-capitaine-icon-theme

Installing Fonts

macOS uses San Francisco for most of its interface, which you can download from Apple directly here. Copy the *.otf files from that repository into /usr/local/share/fonts (your system-wide fonts folder) and refresh the font cache by running `sudo fc-cache`.

Change your fonts in Elementary Tweaks, via System Settings > Tweaks > Fonts

Last Thoughts

Honestly, I really didn’t expect Elementary OS to blow me away. I wasn’t sure how well this experiment will go or how long it would last, but after tweaking Elementary to my liking, I found myself staying on this side of the partition much longer and–most importantly–enjoying the experience 🙂

Please give the instructions a try, and feel free to leave your thoughts and comments below.

Thanks!


Resources