1. Home
  2. Linux
  3. Fix a frozen kde window manager

How to fix a frozen KDE window manager

KDE’s window manager (KWin) has gone over a lot of improvements since KDE Plasma 5 has been released. Among those improvements is the faster overall performance, more customization features, bug fixes, and of course, lower memory usage. The fixes added to KWin are noticeable, and as a result, it is regularly proven to be one of the best window managers on all of Linux. Still, despite all of the fixes, breakages, freezes and crashes still happen.

If you’re dealing with a frozen or crashed KDE window manager on your Plasma 5 desktop, you won’t be able to press a hotkey or tick a setting to fix it. Instead, you’ll need to take matters into your own hands. So, in this guide, we’ll go over how to repair a frozen KDE window manager.

Restart the window manager with a command

The KDE Plasma 5 window manager (KWin) can easily be restarted or re-run if needed. However, unlike forcing the KDE Plasma panel to restart, Kwin cannot be tinkered with from the terminal window. The reason it won’t work this way is that when the window manager is in the process of restarting, all ability to switch between programs (including the terminal) is unavailable.

A better way to deal with stopping the KDE Plasma window manager from running to restart it or re-run it is to use the Krunner quick-launcher that is a part of the Plasma desktop. It is independent of Kwin and will work even if there is no window manager, provided you have access to a keyboard.

To use Krunner to end a broken instance of the KDE Plasma 5 window manager, start by pressing Alt + F2 or Alt + Space on the keyboard. Once the combo is pressed, an app launcher will appear at the top portion of the screen.

Using your mouse, click on the launch box to get Plasma to focus on it. Then, use the killall command to end all running instances of KWin on your Linux PC.

killall kwin

Press Enter on the keyboard to execute the kill command. Soon after, KDE Plasma 5 should lose all ability to render desktop animation effects, and all window controls will be gone. From here, you’ll need to re-run Kwin from Krunner to re-gain access to the window management in KDE.

Re-starting Kwin on KDE Plasma 5, must be re-started directly through Krunner. To do this, Alt + F2 or Alt + Space on the keyboard. Then, click on the text box in the launcher at the top and write in the command below.

kwin --replace

Like before, press Enter to execute the command through Krunner. If the command is successful, Krunner will instantly restart Kwin and give you access to your windows, and any frozen or broken windows should be fixed!

Creating a restart script

Being able to reboot Kwin directly from Krunner when a problem arises is pretty useful, but ultimately, it may be a better idea to set up a reboot script, as you can call it to replace Kwin at a moments notice, rather than dealing with the command-line.

The first step in creating a reboot script is using the touch command to create a blank file labeled “kwin-restart.” Using the terminal, enter the touch command below.

touch kwin-restart

Once you’ve created the new “kwin-restart” script file, use the echo command to add the first line of code to the script. This line of code is critical, as, without it, the interpreter on your Linux PC will not know what to do with the script.

echo '#!/bin/bash' > kwin-restart

Following the shebang, add a line of code that will end all running Kwin processes on the system.

echo 'killall kwin' >> kwin-restart

Using echo, add the third line of code. This line will tell the system to re-start the Kwin window management app.

echo 'kwin --replace &' >> kwin-restart

With all the code added to the “kwin-restart” script, update the permissions of the file using the chmod command.

sudo chmod +x kwin-restart

Install it to the “/usr/bin/” directory with mv.

sudo mv kwin-restart /usr/bin/

Restart Kwin through Krunner by pressing Alt + F2 or Alt + Space on the keyboard, and writing the command below into it.

kwin-restart

Adding the script to a shortcut

Though it’s not necessary, it is possible to run the “kwin-restart” script with a keyboard shortcut. To do this, open up your app menu, search for “Custom Shortcuts” and open up the app with that label.  Then, follow the step-by-step instructions below to set it up as a shortcut.

Note: for more help with shortcuts on KDE, click here.

Step 1: Find the  “Edit” button and click it with the mouse. Then, select “New,”  “Global Shortcut,” and “Command/URL.”

Step 3: Go to “Comment,” and write “Kwin restart” in the box.

Step 4: Click the “Trigger” button in Custom Shortcuts and assign the new custom shortcut to your favorite key-bind. Unsure about what shortcut to use? Try Ctrl + /.

Step 5: Go to “Action,” and write in “kwin-restart”. Then, click “Apply”.

With the shortcut applied, you’ll be able to restart a frozen, non-working KDE Plasma 5 window manager with just a keyboard shortcut!

1 Comment