How to Speed Up Your Linux Desktop with Compton

Compton Feature

Desktop compositors have become a modern necessity, whether it be due to screen tearing or simply a yearning for desktop eye candy. While compositors often come at a cost – speed and resources – a tiny compositor is here to save the day: Compton. Able to run on even the lamest of machines, Compton can smooth out graphics on low-end hardware or make a new machine’s desktop lightning-fast.

For those not in the know, Compton is a super-lightweight standalone compositor designed to be used in conjunction with Linux desktops. Perfect for older hardware, it is often used by lightweight distros that need a compositor that won’t sacrifice speed and responsiveness. We’ve included instructions for three desktops here: KDE, MATE, and Xfce. Note that the same principles can be applied to many other desktops.

We were hoping to include GNOME and Cinnamon, but it appears their compositors are built in and cannot be replaced – let us know in the comments if that’s not the case and how to disable them.

Also read: 5 Customized Linux Desktops to Inspire You

Installing and Using Compton

Compton is very common and should be available in your distribution’s repositories. If not, instructions are included on the project’s GitHub page.

If you prefer to install by command line, for Debian or Ubuntu-based systems, enter:

sudo apt install compton

For Fedora/Red Hat systems:

sudo dnf install compton

This tutorial will cover three steps for each desktop after the point of installation: disabling your compositor, trying Compton in a shell, and adding Compton to your desktop’s list of auto-start programs.

Rather than using the command by itself, we’ll add switches to use OpenGL instead of the old X Render backend, which will give the desired performance.

compton --vsync opengl-swc --backend glx

MATE and Xfce are slightly easier to get working than KDE, so we’ll start there, continuing in order of ascending difficulty.

MATE

Neither of MATE’s or Xfce’s compositors are particularly heavy, but we found Compton was better at handling screen tearing and at least seemed faster than that of MATE or Xfce. (More fastidious users can measure such things!)

To disable your compositor, click “Menu -> Preferences -> Windows.” This will open a new window called “Window Preferences.” Under the General tab, uncheck the box that says “Enable software compositing window manager.”

Compton Mate Disable Compositor

With the compositor disabled, open a terminal and try running Compton. If it runs successfully, add it to MATE’s autostart by clicking “Menu -> Preferences -> Startup Applications.” In the new window, click Add. This will open a dialog for entering your command.

Compton Mate Startup

First, name the command so you can find it (Compton!), and add the full command in the Command field.

Compton Mate Popup

XFCE

Xfce has essentially the same steps as MATE, just with more windows to navigate. Disable your compositor by opening the main Applications menu and clicking “Settings -> Window Manager Tweaks.” This will open a new window. Open the Compositor tab, and uncheck the option “Enable display compositing.”

Compton Xfce Compositor Settings

Check that the command works in a terminal. If so, add it to your startup by clicking “Menu -> Applications -> Settings -> Session and Startup.” In the new window, open the “Application Autostart” tab and click the Add button.

Compton Xfce Autostart Addbutton

In the “Add application” window, name your command, and enter the full command in the Command field. Leave Trigger set to “on login” and click OK.

Compton Xfce Compositor Autostart Popup

KDE

Now this is where Compton will make a significant difference to performance. Compared to KDE’s native compositor, there was a substantial increase in speed and responsiveness. The desktop now reacts so quickly it’s almost violent. A game under Proton was suddenly running at 60+ FPS, where previously it was struggling.

Performance aside, Compton’s visual tweaks look gorgeous under KDE, with a very tasteful translucency on menus.

Compton Kde Pretty Menus

Combined with a dark theme, it gives the taskbar and menus a stylish black glass look, making for one of the most beautiful desktops we’ve ever used.

Compton Kde Showoff

Note that although Compton generally runs well with KDE, it breaks when manually changing desktop resolutions through System Settings. This leaves you half a desktop with all the buttons and inputs in the wrong places. Logging out via keyboard shortcuts fixed the problem, but you should probably disable Compton through your system monitor before changing desktop resolutions.

Also worth noting is that you can no longer zoom out to see all desktops. This is something I rarely use, so I don’t really miss it, but if you rely on this feature, Compton isn’t for you.

Otherwise, Compton was generally more stable than KDE’s compositor, particularly when applications changed resolutions in fullscreen (even DOS games running in very low resolutions). If you’re a hardcore gamer, it’s worth stripping back on features for the serious performance gains on offer.

Getting Compton Working on KDE

To get Compton working with KDE takes more preparation. Don’t panic, as it’s not that hard. Disabling the compositor is easy enough. Just open KDE’s System Settings, go to “Display and Monitor,” open the Compositor section, and uncheck the box “Enable compositor on startup.” Try the given Compton command in a terminal, and if all is well, upi can move on.

Compton Kde Disable Compositor

This is where things get slightly harder. KDE’s Autostart dialogs won’t accept that raw Compton command with its switches, so you’ll have to make a basic script. Don’t worry, we’ll talk you through it.

Start by making a new text file. We’ll be calling it “compton-script.sh.” Copy and paste the following text into it:

#!/bin/bash
 
/usr/bin/compton --vsync opengl-swc --backend glx

Save the file and make it executable by right-clicking on the file and choosing Properties. Open the Permissions tab and check the box “Is executable.”

Compton Kde Permissions

That script is now ready to use. To add it to your startup, open System Settings and choose the “Startup and Shutdown” section where you will find Autostart. Once in Autostart, click the “Add Script” button and browse for your script file in the new dialog window. Click OK and you should be finished.

Compton Kde Startup

Are you still experiencing screen tearing despite an awesome compositor like Compton? See our guide on how to remove screen-tearing from Linux.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

John Knight

John Knight is a writer, most notably for Linux Format (UK), Linux Journal (US), and Maximum PC (US). Outside of open source and general computing material, John has also written for automotive publications, and is currently writing material on vintage gaming and drumming. Other areas of interest include Psychology, French, and Japanese.