Installing Compton on CentOS
Before configuring Compton, you need to install it on your CentOS system. Use the following commands to set it up:
sudo yum update -y (for CentOS 7) or sudo dnf update -y (for CentOS 8/Stream).sudo yum install epel-release -y followed by sudo yum install compton -y. For CentOS 8/Stream, use sudo dnf install compton -y.Configuring Compton
Compton’s configuration is managed via a config file, typically located at ~/.config/compton.conf (user-specific) or /etc/compton.conf (system-wide). If the file doesn’t exist, create it using a text editor like nano or vim. Below are key parameters to customize:
glx (OpenGL, better performance) or xrender (software-based, more compatible). Example: backend = "glx";.shadow = true; and exclude specific windows (e.g., Firefox) to avoid unnecessary rendering. Example: shadow-exclude = ["class='.*Firefox'"];.alpha-mode = "screen"; and alpha-ignores = ["class='.*Firefox'"]; (excludes Firefox from transparency).fade = true; and set the fade duration with fade-delta = 30;.bg.use_desktop_bg = true; and specify the image path: bg.desktop_bg_image = "/path/to/image.jpg";.Example minimal config for performance:
backend = "glx";
shadow-exclude = [".*"];
glx-no-stencil = true;
glx-copy-from-front = true;
Save the file after editing.
Starting Compton
You can start Compton in two ways:
compton --config ~/.config/compton.conf & to start it in the background. The & ensures it runs without blocking your terminal.sudo nano /etc/systemd/system/compton.service.[Unit]
Description=Compton Window Composer
After=display-manager.service
[Service]
ExecStart=/usr/bin/compton --config ~/.config/compton.conf
Restart=on-failure
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable compton.service
sudo systemctl start compton.service
Verifying and Troubleshooting
To confirm Compton is running, use:
ps aux | grep compton: Look for a compton process.systemctl status compton.service: Check the service status (should show “active (running)”).If you encounter issues (e.g., no shadows, high CPU usage), check the Compton log (enable logging by adding log-file = "/var/log/compton.log"; to the config) or run journalctl -u compton.service -e to view systemd logs. Common fixes include adjusting the backend (glx vs xrender) or excluding problematic applications from shadows/transparency.
Performance Optimization Tips
glx for NVIDIA/AMD GPUs (better performance) and xrender for Intel integrated graphics (more compatibility).vsync = true; to sync with your monitor’s refresh rate and frame-rate = 30; to limit rendering to 30 FPS.shadow-exclude (e.g., "[class='.*Chrome']") to reduce rendering load.cache-size = 100M; (default is 50M) to improve performance for complex windows.