Configuration Tips for Compton on CentOS
Compton is a lightweight window compositor that enhances desktop visuals (shadows, transparency, blur) and performance. Below are essential tips for installing, configuring, and optimizing Compton on CentOS systems.
1. Installation on CentOS
Before configuring, install Compton and its dependencies. For CentOS 7/8/9:
- Enable EPEL Repository (for newer versions):
sudo yum install epel-release -y - Install Dependencies:
sudo yum install -y xorg-x11-server-Xorg mesa-libGL wget git cmake make libX11-devel libXext-devel libXrender-devel libXi-devel libXrandr-devel libXinerama-devel libXcursor-devel libXcomposite-devel libasound2-plugins - Install Compton:
- Via Yum (Stable Version):
sudo yum install -y compton - From Source (Latest Version):
Clone the repository, compile, and install:git clone https://github.com/compton/compton.git cd compton mkdir build && cd build cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release make -j$(nproc) sudo make install
- Via Yum (Stable Version):
2. Basic Configuration
Compton’s default config file is located at ~/.config/compton.conf (create it if it doesn’t exist). Key settings for general use:
# Backend (glx for OpenGL acceleration, xrender for compatibility)
backend = "glx"
# Disable shadows for better performance (or customize exclusions)
shadow = false
# Set window transparency (1.0 = opaque, 0.8 = 20% transparent)
opacity = 0.8
# Ignore root window transparency (prevents desktop background issues)
ignore_root = true
# Enable vertical sync to reduce screen tearing
vsync = true
# Multi-monitor support (adjust for your setup)
xrandr-args = "--output HDMI-1 --auto --right-of eDP-1 --output DP-1 --auto --right-of HDMI-1"
Save the file and start Compton with:
compton -c ~/.config/compton.conf
3. Performance Optimization
To minimize resource usage (critical for older hardware):
- Disable Unnecessary Effects: Turn off shadows (
shadow = false) or transparency (opacity = 1.0) if not needed. - Use GPU Acceleration: Ensure
backend = "glx"(requires OpenGL-compatible drivers) for faster rendering. - Limit Cache Size: Add
cache-size = 1024(in MB) to reduce memory usage. - Restrict Framerate: Use
fps-limit = 60to cap rendering at 60 FPS (prevents unnecessary CPU load). - Exclude Apps from Effects: Skip shadow/transparency for resource-heavy apps like Firefox:
shadow-exclude = ["class_g = 'Firefox'", "title_g = 'Firefox'"] opacity-exclude = ["class_g = 'Firefox'"]
4. Advanced Customization
For tailored visuals or specific use cases:
- Background Blur: Enable subtle blur for inactive windows:
blur-background = true blur-kern = "3x3box" # Faster but less smooth; "5x5gaussian" for better quality blur-strength = 5 # Adjust intensity (1-10) - Screen Edge Blur: Add a blurred effect to screen edges (useful for maximizing windows):
screen_edge_blur = true screen_edge_blur_radius = 10 - Custom Transparency Rules: Set transparency for specific windows (e.g., terminals):
opacity-rule = [ "80:class_g = 'URxvt'", # 80% transparent for URxvt terminals "100:class_g = 'Firefox'" # Opaque for Firefox ] - Logging for Debugging: Enable logs to troubleshoot issues (e.g., black screens):
compton -c ~/.config/compton.conf --log-level debug --log-file /tmp/compton.log
5. Autostart Setup
To run Compton automatically on login:
- Create a Systemd Service:
Add the following content (replacesudo nano /etc/systemd/system/compton.service~/.config/compton.confwith your path):[Unit] Description=Compton Window Compositor After=graphical.target [Service] ExecStart=/usr/bin/compton -b -c ~/.config/compton.conf Restart=on-failure User=%i [Install] WantedBy=graphical.target - Enable and Start the Service:
sudo systemctl daemon-reload sudo systemctl enable compton.service sudo systemctl start compton.service - Verify Status:
systemctl status compton.service
6. Troubleshooting Common Issues
- Black Screens or No Effects:
- Check if Compton is running (
ps -e | grep compton). - Verify the config file path (
compton -c /path/to/config). - Test with a minimal config (e.g., only
backend = "glx").
- Check if Compton is running (
- High CPU Usage:
- Disable shadows/blur (
shadow = false; blur-background = false). - Lower the framerate (
fps-limit = 30).
- Disable shadows/blur (
- Compatibility Problems:
- Switch to
backend = "xrender"(less performant but more compatible). - Update graphics drivers (e.g., NVIDIA/AMD proprietary drivers).
- Switch to
By following these tips, you can effectively configure Compton on CentOS to achieve a balance between visual appeal and system performance. Adjust settings based on your hardware and desktop environment (GNOME, KDE, Xfce, etc.) for optimal results.
以上就是关于“配置compton在centos的技巧”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm