centos

compton在centos上的使用技巧

小樊
38
2025-11-03 20:39:03
栏目: 智能运维

Installing Compton on CentOS
Before using Compton, you need to install it on your CentOS system. For CentOS 7 and earlier, use yum; for CentOS 8 and later, use dnf. If Compton is not available in the default repositories, install the EPEL repository first:

sudo yum install epel-release -y  # For CentOS 7
sudo dnf install epel-release -y  # For CentOS 8+
sudo yum install compton -y       # Install Compton

This ensures you have the latest version of Compton compatible with your system.

Configuring Compton
The main configuration file for Compton is located at ~/.config/compton.conf (create it if it doesn’t exist). A basic configuration for multi-monitor setups with performance optimizations looks like this:

backend "glx"  # Use GLX for better performance (alternative: xrender)
shadow-exclude [".*", "[class'.*Firefox']", "[title'.*Firefox']"]  # Exclude Firefox from shadows
alpha-mode "none"  # Disable alpha blending for better performance
alpha-ignores [".*", "[class'.*Firefox']", "[title'.*Firefox']"]  # Ignore Firefox for alpha effects
glx-no-stencil true  # Disable stencil buffer for improved performance
glx-copy-from-front true  # Optimize front buffer copying
shader-file null  # Disable shaders for simplicity
shader-frag null
shader-vert null
xrandr-args ""  # Pass additional arguments to xrandr if needed

Key options:

Starting Compton
You can start Compton manually with your configuration file:

compton -c ~/.config/compton.conf

To ensure Compton starts automatically on boot, create a systemd service file (/etc/systemd/system/compton.service):

[Unit]
Description=Compton Window Composer
After=display-manager.service  # Start after the display manager

[Service]
ExecStart=/usr/bin/compton -c ~/.config/compton.conf
Restart=on-failure  # Restart if it crashes

[Install]
WantedBy=multi-user.target  # Enable for all users

Reload systemd, enable the service, and start it:

sudo systemctl daemon-reload
sudo systemctl enable compton.service
sudo systemctl start compton.service

Check the status with systemctl status compton.service to confirm it’s running.

Optimizing Performance
Compton can consume significant resources, especially with effects like shadows and transparency. To optimize:

Advanced Tips

0
看了该问题的人还看了