在 CentOS 上配置 Compton 的完整步骤
一 环境准备与安装
sudo yum update -y
sudo yum install -y epel-release
sudo yum install -y compton
sudo dnf update -y
sudo dnf install -y compton
sudo yum groupinstall -y "Development Tools"
sudo yum install -y cmake git libX11-devel libXext-devel libXrender-devel \
libXi-devel libXrandr-devel libXinerama-devel libXcursor-devel \
libXcomposite-devel libXdamage-devel libxcb-devel libx11-xcb-devel
git clone https://github.com/Compton/Compton.git
cd Compton && mkdir build && cd build
cmake .. && make -j$(nproc)
sudo make install
以上步骤覆盖 yum/dnf 安装与源码编译两种常见路径,适用于 CentOS 7/8/Stream。二 创建配置文件
compton --config ~/.config/compton.conf --dump-conf > ~/.config/compton.conf
backend = "glx"
vsync = true
fps = 60
shadow = true
shadow-radius = 12
shadow-offset-x = 0
shadow-offset-y = 8
shadow-exclude = [
"name = 'Notification'",
"class_g = 'Conky'",
"class_g = 'Polybar'",
"_GTK_FRAME_EXTENTS@:c"
]
fading = true
fade-in-step = 0.03
fade-out-step = 0.03
mark-wmwin-focused = true
mark-ovredir-focused = true
use-ewmh-active-win = true
detect-rounded-corners = true
detect-client-leader = true
wintypes: {
dock = { shadow = false; }
tooltip = { shadow = false; }
popup_menu = { shadow = false; }
dropdown_menu = { shadow = false; }
}
说明:
三 启动与自启动
compton --config ~/.config/compton.conf --daemon --log-file /tmp/compton.log
mkdir -p ~/.config/systemd/user
nano ~/.config/systemd/user/compton.service
[Unit]
Description=Compton Window Composer
After=graphical-session.target
[Service]
Type=simple
ExecStart=/usr/bin/compton --config /home/your-username/.config/compton.conf --daemon --log-file /tmp/compton.log
Restart=on-failure
Environment=DISPLAY=:0
[Install]
WantedBy=default.target
systemctl --user daemon-reload
systemctl --user enable --now compton.service
四 验证与常见问题
systemctl --user status compton.service
tail -f /tmp/compton.log
cpulimit -l 50 -p $(pgrep compton)