Dell XPS13 9380 Developer Edition

Intro

Ever since 2006 I have preferred Apple's MacBook Pro for its durability and the OS. However the last couple of models have had very little upgrades, the keyboard has become really bad and the OS is becoming more of a walled garden.

On my main desktop I run Linux as the main OS. So when it came time to choose a new laptop for my new job I took the chance to order a Linux based laptop. I chose the Dell XPS 13 (9380) Developer Edition. I could also have chosen a Purism or System76 device, but the purchasing process did not allow for those options.

So far I am very happy with the device. It is built well and comes preloaded with Ubuntu 18.04 LTS. I chose to keep the default OS on it, as it seems to provide the best experience.

On this page you will find some of the tweaks I had to do in order to make it work perfectly.

Hibernation

I found that the XPS 13 (9380) drains it battery while the lid is closed. This is highly annoying as I am one of those people that tends to work on the road a lot. Some research into the subject reveals that Linux has 2 hibernation modes.

Source for the below information: StackOverflow.

To verify which mode is active you run the command cat /sys/power/mem_sleep. This will show you the following output.

[s2idle] deep

Notice the [] around s2idle. This mode basically boils down to "turn off the screen" instead of doing a full on hibernation. Obviously this will drain the battery.

This can be further verified by checking the logs after closing the lid, letting it go to sleep and waking it up. Run sudo journalctl | grep "PM: suspend" | tail -2 in order to see how the kernel dealt with the suspension. You should see something like this.

May 13 18:41:00 mex kernel: PM: suspend entry (s2idle)
May 13 20:52:36 mex kernel: PM: suspend exit

To test the deep sleep setting (I highly recommend you test it before using it) you can toggle the setting by running echo deep > /sys/power/mem_sleep as the root user. Verifying cat /sys/power/mem_sleep should show you:

s2idle [deep]

When you let your machine go to sleep now you can verify the logs to see the kernel did the right thing now (sudo journalctl | grep "PM: suspend" | tail -2):

May 13 18:41:00 mex kernel: PM: suspend entry (deep)
May 13 20:52:36 mex kernel: PM: suspend exit

To permanently fix this issue you need to change the GRUB configuration. Open up the default configuration using sudo -H gedit /etc/default/grub and change the following line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

You will need to add the mem_sleep_default profile to it, as shown below.

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mem_sleep_default=deep"

Now you just need to recreate the active GRUB config by running the following command:

sudo grub-mkconfig -o /boot/grub/grub.cfg

Your laptop should now go into deep hibernation whenever you close your lid, as it should.

U2F Devices in Firefox

Firefox is installed as a snap by default on Ubuntu. I think snap is a wonderful technology. Supported by a nice website, snap aims to be an app store for linux programs. The programs are neatly packed into a single archive and can easily be installed and removed from linux machines. This works similar to the app bundles on macOS I guess.

By default however I noticed that firefox did not accept my Yubikey. At first I thought it came due to my dongle situation, having only USB-C ports, but a quick test in the terminal showed that this is not the case. When you press the yubikey while in a terminal it will show a string of characters that the key sends as a challenge.

So, what does that mean? It turns out that a snap has a set of connections that give it access to certain parts of the OS. By running snap connections firefox we can see what connections (permissions) have been set up for firefox. The below snippet shows the line concerning U2F devices. As you can see the slot is empty (-), meaning that it is not enabled for firefox.

$ snap connections firefox
Interface       Plug                  Slot            Notes
u2f-devices     firefox:u2f-devices   -               -

To connect the U2F devices to firefox all we need to do is to tell snap to make this connection. This is done by running the following snap command: snap connect firefox:u2f-devices. Running the connections command again will show that the slot is now connected and firefox can use U2F devices.

$ snap connect firefox:u2f-devices
$ snap connections firefox
Interface       Plug                  Slot            Notes
u2f-devices     firefox:u2f-devices   :u2f-devices    manual

I think it is kind of silly to have it disabled by default, but now it works like magic.