Skip to content

Instantly share code, notes, and snippets.

@lbrame
Last active July 24, 2024 08:40
Show Gist options
  • Save lbrame/f9034b1a9fe4fc2d2835c5542acb170a to your computer and use it in GitHub Desktop.
Save lbrame/f9034b1a9fe4fc2d2835c5542acb170a to your computer and use it in GitHub Desktop.
Framework Laptop 16 Linux configuration tips

The Framework Laptop 16 is my new laptop of choice that I purchased to replace my dying older machine. It is a sweet machine with phenomenal Linux support, but like all machines, it still has a set of things to know about when using Linux - this time, not really due to broken hardware/firmware, but due to things like high-dpi displays being in a beta state on the Linux desktop.

Hardware configuration

This might be useful for people who stumble onto this gist to debug. My laptop is configured as such, with notes on the Linux support:

  • CPU - AMD Ryzen 7 7840HS
  • GPU - Integrated UMA graphics (AMD Radeon 780M)
  • RAM - Kingston 32 GB kit (2x16), 5600 MT/s, CL40 SODIMM memory
  • SSD - SK Hynix P41 Platinum NVMe 4x4 m.2 2280 format, 2 TB
    • Beware: This disk does not report its size to udisks, so the size shows up as "Unknown" everywhere. Purely a cosmetic issue: your partition size is known, and the installer has no problem setting up partitions on this disk.
    • You cannot run a SMART self-test through GNOME Disks on this disk using GNOME Disks, but you can indeed read the SMART table using smartctl -a /dev/nvme0.
    • The disk runs cool and sips battery, suggesting its sleep states are working well under Linux.
    • You cannot upgrade the firmware of this disk through LVFS, unlike the Solidgm P44 Pro which was, however, much more expensive in my situation. You need a Windows partition or other hacks - I am personally not bothering updating the firmware.

Distro of choice: Fedora Workstation 40

I chose Fedora Workstation 40 because it's officially support and it's a sweet development environment all in all - podman and toolbox are nice to work with, dnf + gdb integration, easy-to-install debug symbols for all packages to help debug upstream, and great support for all on-board hardware as well as nice support for multi-touch gestures are a compelling package.

Setting up Flatpak and Flathub to gain access to more software

Flathub is the accepted central repository to download Flatpak applications through. Flatpak is the next-generation container-based, distro-agnostic, arbitrarily sandboxed packaging system for GUI applications. It provides a host of important advantages over traditional packaging, except for applications like software development, so I recommend using it for most software you install - especially proprietary commercial software, which benefits greatly from the stable and tested runtime target.

flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo

Installing codecs and enabling VAAPI

By default, all codecs and haerdware video acceleration are not configured, although they work splendidly with the onboard AMD platform. This is easily remedied with RPMFusion. These instructions may be out of date if a lot of time has passed - refer to upstream website to double check.

First, add both the free and non-free repos:

sudo dnf -y install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm && \
sudo dnf -y config-manager --enable fedora-cisco-openh264 && \
sudo dnf -y groupupdate core   # Entries in GNOME-Software

Next, swap ffmpeg-free for full-fledged ffmpeg:

sudo dnf -y  swap ffmpeg-free ffmpeg --allowerasing

Next, install the codecs:

sudo dnf -y groupupdate multimedia --setopt="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin && \
sudo dnf -y groupupdate sound-and-video

Finally, install the patched mesa drivers to take advantage of these codecs for hardware acceleration, keeping in mind this will require a reboot to work:

sudo dnf -y swap mesa-va-drivers mesa-va-drivers-freeworld && \
sudo dnf -y swap mesa-vdpau-drivers mesa-vdpau-drivers-freeworld && \
sudo dnf -y swap mesa-va-drivers.i686 mesa-va-drivers-freeworld.i686 && \
sudo dnf -y swap mesa-vdpau-drivers.i686 mesa-vdpau-drivers-freeworld.i686

Speakers: Loading EasyEffects profile

The internal speakers are widely considered to be the not-so-high point of this laptop. However, Framework Forums user cab released a very nice profile to load in EasyEffects to vastly improve the sound that comes out of the speakers.

To apply it:

  1. Download the preset JSON and save it somewhere
  2. Install EasyEffects, either through Flatpak or DNF. I went with the native package on this one
  3. Click on "Presets", then the "Folder" icon, and find the profile file.
  4. Click on "Pipewire", "Presets Autoloading". Choose "Family 17th/19th HD Audio Controller Analog Stereo" from the "Device" dropdown, and add the profile you imported earlier.
  5. Click on the hambuger menu, Preferences, and enable "Launch Service at System Startup"
  6. Reboot the computer.

Next boot, the speakers will sound much better, and will also have more accurate reproduction of high and low frequencies. The only caveat is that this causes a bit of delay. You might hear a slight artifact at the beginning of things like notification sounds. It is for you to decide whether this is worth it. This solution is a stop-gap until official support for laptop speaker DSP lands into Pipewire directly.

Improving battery life, heat and fan emissions with amd-epp-tool

This laptop supports and enables the AMD-pstate EPP CPU scaling driver by default, in a tested way and without requiring to forcibly enable it. However, I have found a great improvement in battery life and heat produced by this mobile workstation by setting the EnergyPerformancePreference from balance_performance to balance_power, which sits in between how power-profiles-daemon sets it upon entering the balanced and power-save profiles.

For a fast way of configuring this driver without having to cat and tee to sysfs manually, I recommend using the excellent amd-epp-tool, installing it following the instructions on the repo, and then using it to set:

  • ScalingGovernor = powersave
  • EnergyPerformancePreference = balance_power

This is already default on battery. Do this any time you are on AC and you feel the laptop is overheating.

Display: disable AMD Vari-Bright to have proper colors on battery

As of Linux kernel 6.9, AMD added the equivalent of Windows feature AMD Vari-Bright to Linux. It is a power saving feature that reduces the contrast and brightness of the panel when on battery and especially when using a power-saving setting in order to preserve battery. It makes the display colours very inaccurate and unpleasant to look at when the laptop is being used on battery.

To revert this, add the amdgpu.abmlevel=0 parameter to the kernel:

grubby --update-kernel=ALL --args="amdgpu.abmlevel=0"

Display: enabling HiDPI Fractional Scaling and VRR

This laptop comes with a gorgeous 16:10 HiDPI VRR display. We will want to take advantage of two experimental Mutter features to set the scale factor to something that gets close to the effective geometry of a Full HD panel, like 150% of 175%, and VRR to make all full-screen content smoother by dynamically matching the screen's refresh rate to the frame rate of the content being displayed, thus eliminating various artifacts:

gsettings set org.gnome.mutter experimental-features "['variable-refresh-rate','scale-monitor-framebuffer']"

You may then access Settings > Display and toggle both of those features on after restarting the compositor.

Explicitly enabling Wayland rendering in apps to get rid of aliasing artifacts when fractional scaling is active

After enabling the scale-monitor-framebuffer experimental feature, even if the selected scale factor is integer, Legacy programs that still use XWayland to render will look blurry and display disturbing aliasing effects, due to the fact that they are being upscaled from their effective size up to the desired scale factor with a bilinear filter. On the other hand, all Wayland clients, at worst, get rendered at a much higher resolution as integer-scaling in a virtual framebuffer, and then a downsampling trick is used to scale them back to the effective display's resolution, which only produces some barely perceptible aliasing. At best, Wayland clients that implement the Wayland Fractional Scale Protocol will ask the compositor about the scale factor and take the matter into their own hands and rendering already scaled in a pixel-perfect fashion, without the resource consumption and slight artifacts of the downsampling trick.

A silver lining is that most clients have flags or options that allow experimental Wayland rendering, which usually comes with drawbacks far more bearable than the extreme artifacting of letting Mutter scale them. The strategy changes based on the toolkit or technology used.

Electron 28+ (Like VS Codium and VS Code)

Electron applications that are based on Electron 28 or later read the ELECTRON_OZONE_PLATFORM_HINT environment variable, which can be used to force Wayland.

mkdir -p ~/.config/environment.d/ && \
echo "ELECTRON_OZONE_PLATFORM_HINT=auto" > ~/.config/environment.d/electron_wayland.conf

Older Electron versions (Like Insomnia)

Older Electron versions can be forced to use Wayland with the following flags:

--enable-features=WaylandWindowDecorations
--ozone-platform-hint=auto

Typically, the way to go for these programs is:

  1. Create a local desktop file where the Exec line is modified to include those flags
  • DNF-installed applications store their desktop files in /usr/share/applications
  • Flatpak System-installed applications store their desktop files in /var/lib/flatpak/exports/share/applications/
  • Flatpak user-installed applications store their desktop files in ~/.var/lib/flatpak/exports/share/applications/
  • The relevant desktop file needs to be copied over to ~/.local/share/applications and then modified in that location for the local override to work
  1. Use the shell profile file (e.g. ~/.profile or ~/.zprofile) or any file sourced at shell startup to declare an alias that overrides the launch command of that application to include the flags.

Electron - note on Flatpak

Sometimes, applications installed through Flatpak have their sandbox set in a way that the Wayland socket is unreachable. Sometimes, enabling access to that socket is sufficient to get the client to use Wayland. Sometimes, that is necessary but it needs to be combined with another strategy. An example of this is Discord, which will require you to enable its Wayland socket, or else it will crash upon you setting the ELECTRON_OZONE_PLATFORM_HINT=auto environment variable.

To do that, either:

flatpak override --user --socket=wayland $APPLICATION_ID

or do it graphically through Flatseal.

For example, Obsidian installed through Flathub can be configured to run on Wayland using the command:

flatpak override --user --socket=wayland md.obsidian.Obsidian

Jetbrains IDEs (IntelliJ IDEA, PyCharm, CLion, RustRover etc.)

For the record, I prefer installing Jetbrains IDEs from their tar archives. In order to display these IDEs in Wayland mode, you need to switch them to the JetBrains Runtime, version 21.. The documentation for how to change runtime is here. From the dialog, make sure to choose a version of the runtime from 21.0 onwards. Finally, from the settings, choose "Edit Custom VM Options..." and paste in:

-Dawt.toolkit.name=WLToolkit

Restart the IDE, and text should look sharp.

Chromium

Although I daily Firefox, I sometimes need to use Chromium-based browsers. For that, navigate to chrome://flags/#ozone-platform-hint and set the flag to Wayland.

Mozilla (Firefox, Thunderbird)

Programs based upon Mozilla's toolkit understand the MOZ_ENABLE_WAYLAND=1 environment variable. As for Firefox, Fedora's preloaded build ran in Wayland with no setup for me, requiring no further action. As for Thunderbird - I installed it through Flathub and I used Flatseal to set the MOZ_ENABLE_WAYLAND=1 environment variable.

Qt

Qt (5 and 6 at the time of writing) applications should already run in Wayland mode natively. But, in case they do not, they can be started with the QT_QPA_PLATFORM=wayland environment variable set.

Fractional scaling and gaming

For those of you who game in your spare time - XWayland also means games. For now, there are very few routes:

  1. Find a way to make the SDL or Vulkan context use Wayland. Trying to run games with SDL_VIDEODRIVER=wayland is a good starting point but expect everything to break.
  2. Go into Settings and temporarily revert the scale factor to 100% before starting Steam or the game's launcher to have the game detect the native resolution.
  3. There is supposedly a way to get aorund this limitation with Gamescope, but I have had no success so far.

Minecraft

Minecraft can take advantage of vulkanmod to work natively on Wayland. I recommend using Prism Launcher.

Factorio

Factorio can be made use Wayland with the SDL_VIDEODRIVER=wayland environment variable.

Graphical artifacts

Some Linux games will have graphical artifacts, because they bundled dependencies are too old for the very recent RDNA 3 graphics. This is easily worked around by forcing the Windows version through Proton. This will, oddly enough, load modern MESA and other dependencies, eliminating the artifacts and improving the performance.

Wrapping up

Framework did a very fine job on this machine. The compnay should take it as a compliemnt that this gist contains zero Framework-specific fixes of workarounds, but more general Linux stuff for laptops with these specs, because no fixes are needed. This is easily the machine I have used that required the least amount of hardware-specific setup to work well: zero. I hope this gist has been useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment