title: "Running Linux on the Thinkpad X13 Yoga (Gen 2)"
---
This is a rather short blog post on how to get the Thinkpad X13 Yoga (Gen 2) working properly on Linux. This includes, making audio work, removing screen tears, making the screen auto rotate, and making the desktop a comfortable size. <!--more-->I'm writing this cause there isn't that much info out there on this system, and hopefully this prevents duplicated efforts.
# Stylus and Touch
Work out of the box! No, seriously! If it doesn't work for you try finding out if your distribution has a Wacom driver package and install that.
# Audio
Out of the box Alsa did not detect any devices whatsoever. Though in the output of lspci it showed that the sound card had Intel snd drivers loaded. The solution to this was to simply download the sof-firmware package, on Ubuntu you need to install firmware-sof-signed.
The video worked well for me mostly, though occasionally the cursor would lag behind, creating ghost copies of itself or terminals would freeze up for a second. I never had any issues with hardware acceleration though. This is solved by adding `i915.enable_psr=0` to the kernel commandline. If you're using GRUB (if you don't know what this means then you are) you need to append this inside the quotes of the line `GRUB_CMDLINE_DEFAULT` in the file `/etc/default/grub`. After saving you changes run `update-grub`. If you're not using grub or running a distro without `update-grub` I'm going to assume you know how to do this.
I've got the 2K version of the X13, because it was cheaper (the more decked out one was for sale). Needless to say that that many pixels on a 13" screen can cause some visibility issues.
To solve this you just need to adjust the DPI setting in the display options.
If you're not using a desktop enviornment this is fixed by adding the following line to your ~/.Xresources.
```
Xft.dpi: 144
```
If you're using xinit/startx you'll also want to add this to your xinitrc (if it's not already there).
```
xrdb -merge "$HOME/.Xresources"
```
# Making the screen auto rotate
Note that you might not need this as some desktop environments handle this automatically.
Long story short, many other people have written, bad, half working scripts. I've hacked together these and written a, less bad, working script.
```
#!/bin/sh -e
# Auto rotate screen based on device orientation
# Might be necessary depending on your environment