Skip to content

Instantly share code, notes, and snippets.

@NotAShelf
Forked from lbrame/archtweaks.md
Last active November 20, 2023 14:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NotAShelf/9d5b65c34159d9896f707aa5543c97e6 to your computer and use it in GitHub Desktop.
Save NotAShelf/9d5b65c34159d9896f707aa5543c97e6 to your computer and use it in GitHub Desktop.
Tweaks I've made to my Arch Linux installation

Arch Linux tweaks

This is a collection of the tweaks and modification I've made to my Arch Linux installation over the months. These may be applicable to other distros, but please check first before doing anything. I also included Arch Wiki references for all the procedures I mentioned. My recommendation is not to blindly follow this gist but to always check with the Arch Linux wiki first. Things move fast and by the time you're reading this my gist may be out of date. Lastly, the golden rule: never execute a command you don't understand.

Also do note that some arguments -or the commands themselves- within those commands may differ based on your hardware such as graphics drivers. Know your hardware and the alternatives to the commands I'm running if your hardware differs greatly (e.g. AMD to NVIDIA)

Installing the KDE Plasma desktop

There are various ways to install it on Arch. The most popular one is to install plasma and plasma-applications, but I don't like doing that because it comes with too many programs I'll never use. Although, I still prefer doing just that and installing all KDE applications, but then removing the ones (believe me, there are a lot) that I will not need.

pacman -S plasma plasma-wayland-session kde-applications
# and remove the ones that you do not need
pacman -R KRuler KAlgrebra KAtomic # etc.

One of the alternatives I have seen is to install the base plasma group, remove the few extra packages that come with it, then finishing off by installing a few KDE apps that don't come with the plasma group, plus packages needed to use some of their features.

I'm aware it's possible to get an even more minimal install by foregoing the plasma group and just installing plasma-desktop and a few other packages, but there are nice features, such as the browser integration, that I actually use.

pacman -S plasma
pacman -Rnsc discover oxygen plasma-vault
pacman -S xdg-desktop-portal ark unrar kdeconnect sshfs dolphin okular konsole kate gwenview

I then export the export GTK_USE_PORTAL=1 environment variable so that programs that read it might load KDE-specific APIs, which can influence some programs to present the Qt file picker over the GTK one - it's way better integrated with Plasma and it's, frankly, superior.

Even though Plasma was built with customization in mind, I mostly use it with its default settings: I just change the action key to META, import my keyboard shortcuts and set the double-click, not the single-click, to open a file or folder.

Yay!

I use yay as my AUR helper. You can install it from the AUR:

mkdir sources && cd sources
git clone https://aur.archlinux.org/yay.git 
cd yay
makepkg -si

If you don't want Golang dependencies, yay-bin is the package you're looking for.

Fonts!

Installing missing fonts

DEs often don't include common fonts that some programs require:

# pacman -S noto-fonts noto-fonts-emoji noto-fonts-cjk ttf-dejavu ttf-liberation ttf-opensans

Enabling ClearType rendering

Microsoft no longer holds their patents on the ClearType font rendering, but at the time of writing only a few select distros (including Ubuntu, Fedora and Void Linux) make use of it by default. However, it can be enabled in Arch by replacing the freetype2 package with a patched version from the AUR

The previously used freetype2-cleartype package has been merged into freetype2 and can be used safely.

# yay -S freetype2

This already improves the situation, but many fonts are still rendered as bitmap, which makes them look horrible. This can, however, be fixed. Let's begin with some symbolic linking:

# ln -s /etc/fonts/conf.avail/70-no-bitmaps.conf /etc/fonts/conf.d
# ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d
# ln -s /etc/fonts/conf.avail/11-lcdfilter-default.conf /etc/fonts/conf.d

Let's then add the following line to /etc/profile.d/freetype2.sh:

export FREETYPE_PROPERTIES="truetype:interpreter-version=40"

Please note that the way I did this is not endorsed by the Arch Wiki and it's a way I found to make the change permament. Unless you know how to revert all of this, you should just stick to what the Arch Wiki does, which I did too anyway.

Create the file ~/.config/fontconfig/conf.d/20-no-embedded.conf and make it look like the following:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="font">
    <edit name="embeddedbitmap" mode="assign">
      <bool>false</bool>
    </edit>
  </match>
</fontconfig>

Finally, log in again. This is an user setting and it will be reverted if you ever delete this file and it won't work on other users.

Installing Windows fonts

While most commonly used fonts (like Times New Roman) are built into the font packages we have previously installed, you can decide to make use of the usual Microsoft fonts by moving them from a Windows installation (if you have one, on your disk) to your fonts directory.

To install them system wide, copy the C:\Windows\Fonts folder from a Windows installation to /usr/share/fonts:

mkdir /usr/share/fonts/WindowsFonts
cp /windows/Windows/Fonts/* /usr/share/fonts/WindowsFonts/
chmod 644 /usr/share/fonts/WindowsFonts/*

These commands assume your Windows partition is mounted at /windows as they've been copied verbatim from the Arch Wiki. If you don't dual boot or don't mount your Windows partition to /windows, just replace /windows/Windows/Fonts/* with wherever location you copied that folder to.

Misc packages

I also install some packages that are generally needed in order to make things work well but don't really fall under any category here:

# in repos
pacman -S \
    libappindicator-gtk3 `#Fixes blurry icons in Electron programs` \
    appmenu-gtk-module  `#Fixes for GTK3 menus` \
    xdg-desktop-portal \
    xdg-desktop-portal `#These two instruct programs to show KDE's file picker whenever possible` \

Improving laptop battery life

Arch Wiki reference: https://wiki.archlinux.org/index.php/TLP https://wiki.archlinux.org/index.php/Powertop

Linux distros tend to deplete laptops' batteries quite quickly, which can be detrimental to some.

Using TLP

tlp is a set-and-forget, auto-tuning option for laptops that I have found to work very well (albeit it comes with drawbacks, such as a perceived decrease in performance). Setting it up on Arch Linux is pretty straightforward:

# pacman -S tlp
# systemctl enable tlp.service --now

Using Powertop

powertop is a powerful commandline program to keep track of battery consumption. It also allows the user to quickly alter some system settings that have an impact on battery life. You can use it to make a quick tuning:

# powertop --auto-tune

However, don't enable powertop's service if you already use TLP.

Using auto-cpufreq

auto-cpufreq is yet another set-and-forget option that I use on my old laptops. While I cannot prove whether or not it provides more benefits than using tlp or powertop, it is designed ultimately replace tlp and has been serving me well for quite some while.

To start the service:

systemctl enable --now auto-cpufreq

Systemd configuration

Arch Wiki reference: https://wiki.archlinux.org/index.php/Systemd/

Taming the journal's size

Systemd's system journal's size can go out of control. There are some things you can do to keep it in control:

# journalctl --vacuum-size=100M
# journalctl --vacuum-time=2weeks

Forwarding the journal to /dev/tty12

This is very simple. Just create the file /etc/systemd/journald.conf.d/fw-tty12.conf and fill it like this:

[Journal]
ForwardToConsole=yes
TTYPath=/dev/tty12
MaxLevelConsole=info

Then, restart the service:

systemctl restart systemd-journald.service

Improving performance on Intel + Intel graphics

I'm using a Intel i7 7700HQ CPU with Intel HD Graphics 630 IGP integrated graphics. It's not a particularly powerful chip by any means, but with some tuning I got it to run very respectably and even allow me to play some lightweight games on the side without framerate drops or having to set low graphics (notably osu, the Portal series, Don't Starve, Starbound, Minecraft and others).

Needed packages

Install necessary packages: (NOTE: You would normally add intel-ucode to the command below, but I usually install it before I even run grub-mkconfig during the installation phase. If you don't have it installed, add it to the command below.)

pacman -S libva-intel-driver libvdpau-va-gl lib32-vulkan-intel vulkan-intel

Intel microcode

Arch Wiki reference: https://wiki.archlinux.org/index.php/Microcode https://en.wikipedia.org/wiki/Intel_Microcode

The first thing you should do on Arch Linux if you have an Intel CPU is setting up intel-ucode.

The first thing to do to set up the microcode on my Intel laptop was to install the intel-ucode package:

# pacman -S intel-ucode

The second thing was to configure my bootloader, GRUB, with microcode early-loading. I just let grub-mkconfig handle this:

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

Finally, reboot.

Setting up VA-API

Arch Wiki reference: https://wiki.archlinux.org/index.php/Hardware_video_acceleration https://wiki.archlinux.org/index.php/Chromium#Hardware_video_acceleration

Something that's really annoying in the Linux desktop is that video acceleration is disabled by default. If you have modest hardware, you'll probably notice watching a YouTube video is enough to bring your CPU near to the maximum usage. This can, of course, be worked around in some ways.

If you use Intel Graphics, you have to find out if your Intel chip requires the intel-media-driver or the libva-intel-driver. My processor supports the latter. It's not installed by default, so you should do it yourself:

pacman -S libva-intel-driver libva-utils

After doing this, look at the output of vainfo, provided by the package libva-utils we have installed earlier, to make sure everything is fine. Lines terminating in VAEntrypointVLD or VAEntrypointEncSlice indicate success.

I use the mpv media player mostly. It's sufficient to start it with arguments mpv --hwdec=auto to enable hardware acceleration for Xorg and mpv --gpu-context=wayland on Wayland. I'm currently using the Plasma desktop which doesn't have very good Wayland support yet at the time of writing, so I'm using a Xorg session. mpv can also be used to play YouTube videos, as long as the youtube-dl package is also installed. The best command for this use case is mpv --hwdec=auto --profile=a4k --ytdl-format="bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4" [link to the youtube video]

Although my primary browser is Firefox, I also want to have a GPU-accelerated browser around to browse intensive websites with and, realistically, to play online videos on - it gets tedious to use mpv all the time. Neither Firefox nor Chromium support VA-API by default, so I use the chromium-vaapi-bin package from the AUR:

yay -S chromium-vaapi-bin

Arch Forums reference: https://bbs.archlinux.org/viewtopic.php?id=244031

However, the work is not over. You should create a ~/.config/chromium-flags.conf that looks like the following:

--force-device-scale-factor=1.25 --ignore-gpu-blacklist --enable-gpu-rasterization --enable-native-gpu-memory-buffers --enable-zero-copy --enable-accelerated-mjpeg-decode --enable-accelerated-video --use-gl=egl --disable-gpu-driver-bug-workarounds

Note: --force-device-scale-factor=1.25 is not a necessary argument to enable GPU acceleration, as all it will do is to scale the Chromium window by 125%. My laptop has a 1080p monitor and I don't find Chromium to scale well by default, and I find the interface much more readable at 125% scale. This value changes depending on your dpi and eyesight.

To make sure this works well, start a YouTube video and then check for the following things:

  • In chrome://media-internals/ > your video stream, a table should show up. The value associated to video_decoder should either be MojoVideoDecoder or GpuVideoDecoder. If it reads anything else but one of these two strings, then you're still using software acceleration.
  • In chrome://gpu "Video Decode" should read "Hardware Accelerated".

Installing the h264ify extension might help in case CPU usage is still too high, but it's a workaround, rather than a solution.

Solaar

My mouse is a Logitech G305. It's fantastic, but Logitech does not provide any Linux software to control some of its settings. Fortunately, FOSS project Solaar helps with this:

pacman -S solaar

I hide its system tray icon because KDE Plasma already tells me my mouse's remaining battery life.

Setting up touchpad gestures

Arch Wiki reference: https://wiki.archlinux.org/index.php/Libinput

libinput-gestures README: https://github.com/bulletmark/libinput-gestures/blob/master/README.md

My laptop comes with an excellent touchpad. Unfortunately, Linux distros don't ship an equally excellent touchpad driver / implementation. The only real fix would be to contribute to the Libinput project and improve it, but for now we can use libinput-gestures as a workaround.

The first thing you should do is to make sure you're using the libinput driver. If you are not, remove the xf86-input-synaptics, xf86-input-evdev packages and reboot. Finally, I'm using Xorg for this and I don't recommend using this hack in Wayland since desktop environments in Wayland typically have better touchpad gestures already.

Once that's cleared, it's time to install AUR package libinput-gestures as well as other packages from the repos we will need.

pacman -S xdotool wmctrl
yay -S libinput-gestures

libinput-gestures will detect touchpad gestures and run a command when any set gesture is detected. xdotool will react to this by simulating keyboard events. To allow xdotool to work, the user you're using should be added to the input group:

gpasswd -a $USER input

My dotfiles already contain a valid ~/.config/libinput-gestures.conf file that works well with a Plasma session set up with my own keybindings. Finally, let's finish the setup:

libinput-gestures-setup autostart
libinput-gestures-setup start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment