Installing Compton on Ubuntu
To use Compton for enhanced window effects on Ubuntu, start by installing it via the package manager. Open a terminal and run:
sudo apt update && sudo apt install compton
This command installs the latest version of Compton available in Ubuntu’s repositories. For newer versions or custom builds, you can compile from source (e.g., cloning the GitHub repository), but the package manager method is recommended for stability.
Configuring Compton
Compton’s configuration is managed via a text file, typically located at ~/.config/compton.conf. If this file doesn’t exist, create it using a text editor (e.g., nano):
mkdir -p ~/.config && nano ~/.config/compton.conf
Below are key configuration options to customize Compton’s behavior:
xrender (default, stable) or glx (better performance with GPU support). Add this line to your config:backend = "glx";
shadow = true; # Enable shadows
shadow-radius = 12; # Blur radius
shadow-offset-x = -15; # Horizontal offset
shadow-offset-y = -15; # Vertical offset
shadow-opacity = 0.75; # Opacity (0-1)
shadow-exclude = [ # Exclude specific windows (e.g., notifications)
"name = 'Notification'",
"class_g = 'Conky'",
"class_g = 'Cairo-clock'"
];
inactive-opacity = 0.8; # Opacity for inactive windows (0-1)
active-opacity = 1.0; # Opacity for active windows
frame-opacity = 0.7; # Opacity for window frames
fading = true; # Enable fading
fade-delta = 5; # Animation speed (lower = faster)
fade-in-step = 0.03; # Fade-in increment
fade-out-step = 0.03; # Fade-out increment
glx-no-stencil = true; # Disable stencil buffer (improves performance)
glx-no-rebind-pixmap = true; # Prevents unnecessary pixmap rebinding
xrender-sync-fence = true; # Synchronizes X11 rendering (reduces tearing)
unredir-if-possible = true; # Disables compositing for fullscreen applications (saves resources)
Save the file after editing. For detailed explanations of all options, refer to the official Compton documentation.
Applying Configuration Changes
After modifying the config file, restart Compton to apply the changes. Run the following command in the terminal:
pkill compton && compton -b --config ~/.config/compton.conf
The -b flag runs Compton in the background, and --config specifies the path to your custom config file.
Setting Up Compton to Start Automatically
To ensure Compton launches on system boot, create a systemd service file:
sudo nano /etc/systemd/system/compton.service
Add the following content to the file:
[Unit]
Description=Compton Window Compositor
After=graphical.target
[Service]
ExecStart=/usr/bin/compton --config /etc/compton.conf
Restart=on-failure
[Install]
WantedBy=graphical.target
Save the file, then enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable compton
sudo systemctl start compton
This configures Compton to start automatically when you log in to your Ubuntu session.
Troubleshooting Common Issues
vsync setting in your config file. Try:vsync = "opengl-swc"; # or "opengl", "drm"
backend = "xrender" and enable paint-on-overlay = true.shadow-exclude or opacity-rule. For example, to disable transparency for Firefox:opacity-rule = ["90:class_g = 'Firefox'"]; # Sets opacity to 90% for Firefox
Check Compton’s logs for errors by running it in the foreground:
compton --config ~/.config/compton.conf
This will display real-time output that can help diagnose issues.