在 CentOS 上配置 compton(现在社区更常用的是它的分支 picom)一般步骤如下。下面以 CentOS 7 / 8 为例,假设你使用的是 X11 桌面环境(如 GNOME、XFCE、MATE 等)。
compton 只支持 X11,不支持 Wayland。
echo $XDG_SESSION_TYPE
输出应为:
x11
如果是 wayland,需要先切换到 X11 会话。
sudo yum install -y epel-release
sudo yum install -y compton
sudo dnf install -y epel-release
sudo dnf install -y compton
如果仓库中没有
compton,建议直接装 picom(见下文)。
sudo dnf install -y picom
或者从源码编译(功能更新):
sudo dnf install -y git meson ninja-build gcc make \
libconfig-devel dbus-devel pixman-devel xcb-util-devel \
xcb-util-image-devel xcb-util-renderutil-devel
git clone https://github.com/yshui/picom.git
cd picom
meson setup build
ninja -C build
sudo ninja -C build install
配置文件通常位于:
~/.config/compton.conf
# 或 picom
~/.config/picom.conf
backend = "glx";
vsync = true;
shadow = true;
shadow-radius = 12;
shadow-opacity = 0.5;
shadow-offset-x = -2;
shadow-offset-y = -2;
fade = true;
fade-in-step = 0.03;
fade-out-step = 0.03;
opacity-rule = [
"90:class_g = 'Firefox'",
"80:class_g = 'URxvt'"
];
unredir-if-possible = true;
compton --config ~/.config/compton.conf -b
# 或 picom
picom --config ~/.config/picom.conf -b
-b 表示后台运行。
把启动命令加到「启动应用程序」:
compton --config ~/.config/compton.conf -b
mkdir -p ~/.config/systemd/user
创建:
~/.config/systemd/user/compton.service
内容:
[Unit]
Description=Compton compositor
After=graphical-session.target
[Service]
ExecStart=/usr/bin/compton --config %h/.config/compton.conf -b
Restart=on-failure
[Install]
WantedBy=default.target
启用:
systemctl --user enable compton
systemctl --user start compton
vsyncbackend = "xrender"建议使用:
backend = "xrender";
vsync = false;
unredir-if-possible = true;
ps aux | grep compton
如果你能告诉我:
我可以给你一套更精确的配置。