Compositors are a very important part of the aesthetics of any linux desktop environment. In this blog, we will be looking at the following:
- What are Compositors
- How Compositors Work
- When to use a Compositor
- When NOT to use a Compositor
- The Compton Compositor
- The Picom Compositor
- Configuring the Compositor
- Useful Links
A compositor is a software which interacts with the window system as well as graphics in linux to produce:
- Transparency in windows
- Transition animations
- Drop shadows around windows which give them a 3D effect
- V sync: Waits for the display to update before updating the display
As you can see, using compositors in a linux desktop environment adds flavour to the aesthetics. Now let us see how they work.
The compositer causes an entire sub-tree of a window hierarchy to be rendered to an off-screen buffer. Applications can then take the contents of that buffer and do whatever they like.
The off-screen buffer can be automatically merged into the parent window or merged by external programs, called compositing managers. Maintaining a buffer like this makes it easy to add additional frames during a window state change, such as fade-in and fade-out animations. Each frame of each running application goes through the compositor.
A compositor should be used if there is a need of transparency, transition animations, v-sync and similar aesthetic features. Note that most desktop environments (like gnome) come with their own integrated compositors. Even some window managers like Compiz, Enlightenment, KWin, Marco, Metacity, Muffin, Mutter, Xfwm, do compositing on their own.
You would need to install a compositor separately if you are using a minimalistic desktop environment of window manager such as dwm, i3 or awesome. In such a case, since the environment is bare-bones (in the order of 1 to 5 megabytes), it is not shipped with a compositor off the shelf. In such cases, compositors like compton or picom can be used.
The mechanism behind a compositor revolves around maintaining an off-screen buffer and passing that around different windows. While this might add a lot of effects to your window manager or desktop environment, it is NOT ideal during gaming, where it causes latency.
While gaming, not using a compositor might lead to the lack of v-sync (unless you turn v-sync on in-game) and a lot of screen tearing, but it does away with latency between frames. I would recommend turning the compositor off while gaming. The drawbacks can be avoided if hardware V-sync is used, but it requires altering the X11 config for synchronization at a graphics driver level. Specifically, enabling the ForceFullCompositionPipeline option for use with nvidia graphics (and TearFree option in the case of Intel) . In such a case, the compositor would not have to be turned off while gaming since v-sync will be offloaded to the graphics driver instead of the compositor itself. This would of course require the v-sync in the compositor to be turned off.
Compton is a light weight and standalone compositor for the X Window System. It is a fork of the xcompmgr-dana compositor, which in turn is a fork of the xcompmgr compositor.
In addition to xcompmgr-dana, it supports the OpenGL backend, as well as colored drop-shadows. It can be easily installed for your distribution using official repos. For debain it can be installed like this:
# install comption sudo apt install compton # run compton in the background compton &
Compton can be added as a startup script for the window manager of your choice.
Although compton is a pretty solid standalone compositor for X11 but sadly it is not regularly maintained anymore. Picom is an active fork of compton which aims to battle the code complexity of compton in order to draw more developers into contributing to the project.
For getting started with picom, I recommend building it from source. For debain based systems, the following dependancies need to be installed and subsequently, the following commands can be used to build picom:
# Debian specific command. The next few commands are for all distros sudo apt install libxext-dev libxcb1-dev libxcb-damage0-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-randr0-dev libxcb-composite0-dev libxcb-image0-dev libxcb-present-dev libxcb-xinerama0-dev libxcb-glx0-dev libpixman-1-dev libdbus-1-dev libconfig-dev libgl1-mesa-dev libpcre2-dev libevdev-dev uthash-dev libev-dev libx11-xcb-dev # clone the project and go into it git clone https://github.com/yshui/picom && cd picom # Use the meson build system (written in python), to make a ninja build meson --buildtype=release . build # Use the ninja build file to proceed ninja -C build # Copy the resultant binary into PATH cp build/src /usr/local/bin # Run picom in the background (this command can be added to the autostart) picom &
Compositors like compton and picom are highly configurable. From customized colored drop shadows, to the amount of transparency can be set both globally, and for certain windows in specific.
A sample config for picom can be found in
/etc/xdg/picom.conf. Here is a copy of the same. To get started, simply copy the configuration to
cp /etc/xdg/picom.conf ~/.config/picom/ vim ~/.config/picom/picom.conf
All of the available options are mentioned in the comments. After making a change, simply edit the configuration and save. The compositor will reload automatically.
To add a compositor to your window manager, simply put the following line in your
# Start compositor in the background picom & # or compton & (in case you want to use compton) # Execute window manager exec awesome
This is a development branch, bugs to be expected
This is forked from the original Compton because it seems to have become unmaintained.
The current battle plan of this fork is to refactor it to make the code possible to maintain, so potential contributors won't be scared away when they take a look at the code.
We also try to fix bugs.
The original README can be found here
Call for testers
This flag enables the refactored/partially rewritten backends.
Currently, new backends feature better vsync with the xrender backend and improved input lag with the glx backend (for non-NVIDIA users). The performance should be on par with the old backends.
New backend features will only be implemented on the new backends from now on, and the old backends will eventually be phased out after the new backends stabilize.
To test the new backends, add the
--experimental-backends flag to…
Compton is a compositor for X, and a fork of xcompmgr-dana.
I was frustrated by the low amount of standalone lightweight compositors Compton was forked from Dana Jansens' fork of xcompmgr and refactored. I fixed whatever bug I found, and added features I wanted. Things seem stable, but don't quote me on it. I will most likely be actively working on this until I get the features I want. This is also a learning experience for me. That is, I'm partially doing this out of a desire to learn Xlib.
Changes from xcompmgr:
- OpenGL backend (
--backend glx), in addition to the old X Render backend.
- Inactive window transparency (
-i) / dimming (
- Titlebar/frame transparency (
- Menu transparency (
-m, thanks to Dana).
- shadows are now enabled for argb windows, e.g. terminals with transparency
- removed serverside shadows (and simple compositing)…