KDE Plasma
This document explains how to install the KDE Plasma desktop environment on Alpine Linux.
GUI Systems: X11 and Wayland
In the early days of computing, punched paper tapes were used for data input and output. Eventually, these paper tapes gave way to punched paper cards for input and printed text (also paper) for output. Paper later gave way to keyboard and magnetic storage (disk) input and Cathode Ray Tube (CRT) monitor output (which was derived from early television and radar work). Until the 1980s, computers primarily worked in text for input and output. Commands were given in text, and the results were displayed in text. Some special-purpose applications could draw graphics to a plotter, and rudimentary ways of drawing shapes on CRT monitors also developed.
By the 1980s, the modern Graphical User Interface (GUI) began to come into use. Xerox developed many of the GUI concepts we use today during the 1970s, and these eventually reached commercialization with Apple computers in the early 1980s. Microsoft released Windows 1.0 in late 1985. At the same time, a group of MIT researchers developed what would become the X Window System in 1984, building upon Stanford research from the early 1980s. Version 11 of the X Window System protocol became standardized as X11 and has been in use on UNIX systems ever since. From 1991, XFree86 was the standard distribution of software that implemented the server side of the X11 protocol on Linux computers. After a licensing dispute in 2004, most of the developers left the XFree86 project and forked the code as X.org.
The X11 protocol contains numerous functions that are outdated today, such as drawing primitive shapes and rendering ugly bitmap fonts. To escape the technical debt of the old protocol, a group of developers created Wayland as a replacement protocol in 2008. Since that time, GUI development effort for Linux has gradually shifted from X11 to Wayland, leaving X.org “largely abandoned” since 2020. Although progress in migrating to Wayland has picked up pace in recent years, there are still some issues with the new protocol. Worse, the issues vary by compositor, which is what a piece of software implementing the server side of the Wayland protocol is called. Unlike X.org, which was the server component for the X11 protocol, there is no single compositor implementation for Wayland. Instead, each developer who wants to build a Wayland GUI implements their own compositor. On the plus side, some compositors develop features more quickly with this approach. The downside is fragmentation and feature disparity between GUI implementations.
Window Managers and Desktop Environments
In the X.org days, Linux users had a wide selection of window managers from which to choose, including ones like Openbox, IceWM, and i3. By running a window manager with a file manager and other independent programs, a user could create a custom desktop environment. Window managers came in two major varieties: stacking and tiling. In a stacking window manager, windows can overlap, and the user is typically responsible for arranging windows on the screen. Microsoft Windows, macOS, Openbox, and IceWM are all examples of the stacking approach. In contrast, tiling window managers like i3 do not allow windows to overlap, and they have more automation for organizing windows on the screen (at the expense of less flexibility for the user).
Over time, preconfigured sets of applications generally consisting of a window manager, file manager, and related tools were bundled together into desktop environments. Examples of desktop environments include KDE Plasma, GNOME, and Xfce, among others. Desktop environments typically provide a unified experience with minimal setup effort at the cost of lower customization.
Today, KDE and GNOME are arguably the most dominant desktop environments, although they are certainly not the only ones. Both desktop environments have well-developed Wayland compositors and have reached the point of usability with Wayland instead of X11. There are also some standalone Wayland compositors that try to fill the role of old X11 window managers, including LabWC and Wayfire. While these compositors have seen quite a bit of development, standalone applications for implementing the remaining components seem to be lagging behind. As such, GNOME and KDE currently provide the best user experience with Wayland.
KDE Plasma and Applications
Since version 4, KDE is actually split into two sets of components: the Plasma desktop itself, which provides the basic desktop and window management features, and a set of cohesive applications that provide the components users expect from a desktop environment. In Alpine Linux, the plasma-desktop-meta package pulls in the core Plasma components. The various kde-applications- packages are used to install the various desktop applications.
Alpine Linux has a kde-applications package, which is a metapackage, or a package that doesn’t install any files but instead depends on other packages. Installing a metapackage thus results in installing all the packages on which it depends. Metapackages can depend on other metapackages, allowing a single metapackage to result in the installation of quite a bit of software.
By using the Alpine Linux Package Index, it is possible to list the dependencies of a package. By setting the Branch to the version being used and picking the correct architecture, one can narrow the package set to the correct Alpine release and architecture. To search for packages, using wildcards (especially *) improves the matching. For example, searching for kde-applications will show the top-level metapackage that installs all KDE applications that have been packaged for Alpine Linux. Searching for kde-applications-* shows the metapackages for each category of applications.
Some of the applications metapackages are currently empty, since native Alpine packages for some of these programs are not available. The kde-applications-games package falls into this category. In addition, some KDE applications are perpetually buggy, such as those in the kde-applications-pim metapackage. For these reasons, I normally recommend installing a subset of kde-applications- metapackages instead of installing the whole kde-applications package.
Fonts
A desktop environment requires fonts in order to display contents properly. A good selection of system fonts makes graphical desktop environments and documents look better. However, it is important to remember that fonts are copyrighted intellectual property, and not all of them are free to distribute. Fortunately, there are plenty of open fonts that can be freely distributed, and packages for these fonts are available in Alpine Linux. Some open fonts are intentionally designed to be the same size as corresponding proprietary fonts, so that documents originally written using proprietary fonts will be visually similar when rendered with the freely distributed fonts.
Installation
Begin by installing a decent selection of fonts:
doas apk add font-inconsolata font-dejavu font-noto font-noto-cjk
doas apk add font-awesome font-noto-extra font-liberation font-carlito
Now the Plasma portion of KDE Plasma can be installed like so:
doas apk add plasma-desktop-meta xf86-input-libinput
To install the KDE applications to go with the Plasma desktop, run:
doas apk add kde-applications-accessibility kde-applications-admin
doas apk add kde-applications-base kde-applications-network
doas apk add kde-applications-utils
Scaling Configuration
In the event that you have a 4K monitor/TV or decide to connect an Alpine-powered Pi to one in the future, you may find that the KDE panel is a bit too small at the bottom. To rectify this situation, I like to drop in a configuration script that KDE will execute at startup. This script sets the environment variable PLASMA_USE_QT_SCALING to 1, improving the 4K experience.
KDE reads startup scripts from a location that is normally written in documentation as XDG_CONFIG_HOME/plasma-workspace/env. The value of XDG_CONFIG_HOME on basically any Linux system is $HOME/.config, which refers to a hidden .config directory in the user’s home directory. Technically, the system administrator can define another directory instead, but there would rarely be any reason to do so.
We need to create the plasma-workspace environment scripts directory first, since it doesn’t yet exist. Then, we can open Neovim to create our script:
mkdir -p $HOME/.config/plasma-workspace/env
nvim $HOME/.config/plasma-workspace/env/scaling.sh
The script only needs to contain one line:
export PLASMA_USE_QT_SCALING=1
KDE Plasma Launch Script
We can’t quite launch KDE Plasma directly, since we need to be sure that the D-Bus session bus is running first, and nothing starts it by default. The most reliable way I’ve found to ensure that it gets started is to create a create a wrapper script, which I usually name “startkde”. Let’s create this this file in /tmp (the temporary directory) initially:
nvim /tmp/startkde
Into this file, carefully add the following script content. If the spell checker is annoying, remember that you can run :set nospell from normal mode to turn it off.
#!/bin/sh
dbus=
if [ -z "${DBUS_SESSION_BUS_ADDRESS}" ]; then
dbus=dbus-run-session
fi
exec ${dbus} startplasma-wayland "$@"
Double-check your work! Be sure that you didn’t add any extra spaces around the
= signs. Unlike Python, shell scripts do not permit spaces in variable
assignment statements. Also check the first line of the file to be sure it
says #!/bin/sh
exactly. This line is called the “shebang line,” named
for the British “hash” (#) and “bang” (!) characters. When we run the startkde
command, the Linux kernel opens our script file and sees this line. In turn,
this shebang line instructs the kernel to use /bin/sh to interpret this script.
Without this line, the kernel won’t know what to do with our file. Once you’re
sure you have the code correct, save the file and quit Neovim.
To make the script available, we first need to put it into a location where the system can find it. Since this is a script we wrote, we’re going to put it in /usr/local/bin. We also need to set its ownership to the root user and group, and we need to give it execute permissions. Run the following commands to perform these tasks:
doas mv /tmp/startkde /usr/local/bin/startkde
doas chown root:root /usr/local/bin/startkde
doas chmod 755 /usr/local/bin/startkde
Starting KDE Plasma
To be sure that our shell can “see” our new launch script, run:
rehash
Once that’s done, you should be able to start the desktop environment using:
startkde
After a brief delay, you should have a shiny new desktop environment! If not, then please recheck the previous steps (and the steps from the previous assignment), as you may have missed something important.
Configuring Plasma Settings
On the panel at the bottom of the screen, you will see some icons on the left side. The first icon is the menu, which works the same way as the Windows start menu, only with a lot less clutter and no advertising. The second icon, which is a dark-colored square with some sliders on it, opens the System Settings dialog. Click this icon to open System Settings.
In the following steps, we’re going to change just a few of the settings for the purposes of this assignment. To navigate between settings categories, click the category on the left side of the System Settings window. Be sure to click the Apply button to save settings before changing categories, or you will get a popup dialog asking you if you want to save the changed settings.
Teal and Bronze Theme
Navigate to Colors & Themes under the Appearance & Style header. Click the little right arrow icon next to the Colors & Themes text to open all the theme settings.
- Leave the Global Theme set to Breeze.
- Under Colors, select the Breeze Classic theme. Then, click the little pencil icon in the lower right corner of the box for the Breeze Classic theme.
- In the dialog that appears, scroll down to the entry for Active Titlebar, and click the little grayish color box on the right side of the entry.
- A color picker dialog will appear. Go down to the HTML box near the bottom right, and enter #006f71. Press the Enter key to accept and set the Active Titlebar to teal.
- Scroll down to Inactive Titlebar. Click the light gray box on the right side of this entry. Do the same thing with the color picker, except enter the HTML code #a27752 for bronze.
- Click the Save As… button at the bottom of the dialog. You will be prompted for a name. Enter CCU and press Enter. Click the Close button at the bottom of the dialog.
- Back in the Colors settings, click on the CCU color scheme box (NOT the pencil or trash can icons!). Click Apply. You should now have a teal window title bar.
Disable Desktop Search
As a general rule, I recommend disabling desktop file search. While file search is convenient, its search index creates a forensically recoverable artifact that an attacker could use to locate sensitive information rapidly. Some people feel that the benefits of file search outweigh this risk, in which case it is fine to leave this functionality enabled as long as the system is using a mechanical hard drive or good-quality solid state drive. For devices that use eMMC or MicroSD cards for storage (like the Raspberry Pi), it is important to disable file search to reduce the number of writes to the storage media. Maintaining the search index will cause these inexpensive flash storage devices to wear out more quickly.
To disable file search, use the little left arrow icon in the upper left corner of the System Settings window to navigate back to the main list of settings. Scroll down and click Search. The File Search settings are shown. UNcheck the box next to Enabled, and click Apply. You can then click the Delete Index Data button that appears to clean up any existing index file.
Region & Language
By default, KDE Plasma on Alpine Linux uses the “C” locale, which contains the default locale settings provided by the musl C library. These default settings use British formats for things like dates and paper sizes. To change the region to American English, go to the top level of System Settings in KDE Plasma, then navigate to the Region & Language settings. Next to each of the following categories, click Modify, and change the respective setting to its American English option. Be sure to click the Apply button after each change, and ignore any warning messages that appear in the process. Changes will not take effect immediately – this is normal.
- Language
- Numbers
- Time
- Currency
- Measurements
- Paper Size
You can leave the Data and Storage Sizes set to the default International Electrotechnical Commission settings, as these sizes are standard on Linux systems in general.
Click the Apply button when you have finished changing all the settings. You might see another warning message. However, these settings will take effect the next time you start the KDE Plasma desktop environment.
Troubleshooting
If you do not see the American English options when changing the settings, then you probably don’t have the musl-locales package installed. Open a Konsole window (under the System category in the start menu) and run:
doas apk add musl-locales
Close and re-open the System Settings application. The American English options should now be present.
Spell Check
Spell check is a useful feature to have, but we need to enable it first. Open the System Settings again. Navigate down to the Spell Check settings.
- Under Preferred Languages, check the box next to American English.
- Check the box next to Automatic spell checking enabled by default.
- Press the Apply button.
Troubleshooting
If the American English language isn’t available for spell checking, then the hunspell-en-us package isn’t installed. Install that package (see the Troubleshooting note in the previous section), then restart the Systems Settings application.
Changing Wallpaper
The easiest way to change the desktop wallpaper is to right click anywhere on the desktop and pick Configure Display and Wallpaper. KDE Plasma includes several choices of wallpaper, many of which are more visually appealing than the default wallpaper that is used the first time the desktop is run.