Installing Compton on CentOS: A Step-by-Step Guide
Compton is a lightweight window compositor designed to enhance desktop visuals with effects like shadows and transparency. It works best with OpenGL-compatible hardware and requires proper dependencies and configuration for optimal performance on CentOS.
1. Update System and Install Core Dependencies
Before installing Compton, ensure your system is up-to-date and install essential libraries for compilation and graphics rendering:
sudo yum update -y
sudo yum groupinstall "Development Tools" -y # Installs compilers (gcc, make) and build tools
sudo yum install -y mesa-libGL mesa-libEGL libX11-devel libXext-devel libXrender-devel libXi-devel libXrandr-devel libXinerama-devel libXcursor-devel libXcomposite-devel libXdamage-devel
These packages provide the OpenGL context, X11 window system support, and development headers needed for Compton.
2. Install Compton via Package Manager (Recommended)
The easiest way to install Compton is using the EPEL repository (Extra Packages for Enterprise Linux), which hosts community-maintained software for CentOS:
sudo yum install epel-release -y # Enable EPEL repository
sudo yum install compton -y # Install Compton from EPEL
This method ensures automatic dependency resolution and simplifies future updates.
3. Compile and Install Compton from Source (Alternative)
If Compton is not available in your EPEL repository (e.g., older CentOS versions), compile it from source for the latest features:
# Clone the Compton repository (replace with official repo if needed)
git clone https://github.com/Compton/Compton.git
cd Compton
# Create a build directory and compile
mkdir build && cd build
cmake .. # Configure build with default options
make -j$(nproc) # Compile using all CPU cores
sudo make install # Install to /usr/local/bin
Compiling from source is useful for customizing Compton (e.g., enabling/disabling features) but requires more time and disk space.
4. Configure Compton for Your Desktop Environment
Compton’s behavior is controlled by a configuration file. Create or edit ~/.config/compton.conf (user-specific) or /etc/compton.conf (system-wide) to tailor settings:
mkdir -p ~/.config
cat <<EOF > ~/.config/compton.conf
# Use OpenGL for better performance (glx) or X11 (xrender)
backend = "glx";
# Enable shadows (adjust offsets/colors as needed)
shadow = true;
shadow-offset-x = 5;
shadow-offset-y = 5;
shadow-radius = 10;
shadow-color = "#00000080"; # Semi-transparent black
# Exclude windows from shadows (e.g., dialogs, popups)
shadow-exclude = [
"class_g = 'GtkDialog'",
"class_g = 'KDialog'",
"window_type = 'dock'",
"window_type = 'desktop'"
];
# Enable opacity for inactive/translucent windows
opacity = 0.9;
inactive-opacity = 0.8;
active-opacity = 1.0;
# Sync with vertical refresh to prevent tearing
vsync = true;
EOF
Key options:
backend: Chooseglx(OpenGL, better performance) orxrender(X11, wider compatibility).shadow: Customize shadow appearance or disable (false) to improve performance.opacity: Adjust window transparency (1.0 = opaque, 0.0 = fully transparent).
5. Start Compton and Enable Auto-Start
Manual Launch
Run Compton with your configuration file to test it:
compton --config ~/.config/compton.conf &
The & runs Compton in the background.
Auto-Start on Login
To launch Compton automatically when you log in, create a systemd user service:
sudo nano /etc/systemd/system/compton.service
Add the following content (replace your-username with your actual username):
[Unit]
Description=Compton Window Compositor
After=display-manager.service
[Service]
Type=simple
ExecStart=/usr/bin/compton --config /home/your-username/.config/compton.conf
Restart=on-failure
User=your-username
[Install]
WantedBy=multi-user.target
Save the file, then enable and start the service:
sudo systemctl daemon-reload # Reload systemd to recognize new service
sudo systemctl enable compton # Enable auto-start at boot
sudo systemctl start compton # Start Compton immediately
Check the service status to ensure it’s running:
sudo systemctl status compton
Look for “active (running)” in the output.
Troubleshooting Tips
- No Effects Visible: Verify Compton is running (
ps -e | grep compton). If not, check for errors in the terminal when launching it manually. - Performance Issues: Disable shadows (
shadow = false) or lower theshadow-radiusin the config file. Switching tobackend = "xrender"may also help on older hardware. - Compatibility Problems: Ensure your graphics driver is up-to-date (NVIDIA/AMD/Intel). Run
lspci -k | grep -A 3 VGAto check your GPU and driver.
By following these steps, you can successfully install and configure Compton on CentOS to enhance your desktop experience with smooth visuals and transparency effects.
以上就是关于“CentOS Compton驱动安装步骤”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm