首页/发现新知
视界 · 深度阅读

compton centos怎样去配置

你提到的 “Compton” 是一个在 Linux 上常用的轻量级合成器(compositor),用于实现窗口透明、阴影、淡入淡出等特效。在 CentOS 上配置 Compton 通常适用于 CentOS 7 / 8 且使用 X11 桌面环境(如 GNOME、XFCE、MATE 等)。

下面我按从安装到配置给你一个完整流程。


一、确认环境

1. 确认使用的是 X11(不是 Wayland)

Compton 不支持 Wayland。

echo $XDG_SESSION_TYPE

输出应为:

x11

如果是 wayland,需要切回 X11(GNOME 登录界面选 “GNOME on Xorg”)。


二、安装 Compton

CentOS 7

sudo yum install epel-release -y
sudo yum install compton -y

CentOS 8(已 EOL,可用 Stream 或手动)

sudo dnf install epel-release -y
sudo dnf install compton -y

如果仓库没有:

sudo dnf install compton xcompmgr -y

三、创建配置文件

Compton 默认读取:

~/.config/compton.conf

创建目录和文件:

mkdir -p ~/.config
vim ~/.config/compton.conf

基础配置示例(推荐)

# 开启阴影
shadow = true;
shadow-radius = 12;
shadow-opacity = 0.5;
shadow-offset-x = -5;
shadow-offset-y = -5;

# 透明
inactive-opacity = 0.9;
active-opacity = 1.0;

# 淡入淡出
fade = true;
fade-in-step = 0.03;
fade-out-step = 0.03;

# 后端
backend = "glx";
glx-swap-method = "undefined";

# 排除某些窗口
shadow-exclude = [
  "class_g = 'Docky'",
  "class_g = 'Conky'"
];

四、启动 Compton

手动测试

compton --config ~/.config/compton.conf

如果没有报错,说明配置正常。


五、开机自启动

GNOME / XFCE / MATE

mkdir -p ~/.config/autostart
vim ~/.config/autostart/compton.desktop

内容:

[Desktop Entry]
Type=Application
Name=Compton
Exec=compton --config ~/.config/compton.conf
X-GNOME-Autostart-enabled=true

六、常见问题

1. 透明不生效

  • 确保窗口管理器支持 RGBA
  • 使用:
compton --backend glx

2. 屏幕闪烁

尝试:

vsync = true;

3. CentOS 8 无 compton

可考虑:

  • picom(Compton 的 fork)
sudo dnf install picom

七、Compton vs Picom(建议)

现在更推荐 Picom

  • 更活跃
  • 支持更多特效
  • CentOS Stream / Rocky / Alma 可用
picom --config ~/.config/picom.conf

如果你能告诉我:

  • CentOS 版本(7 / 8 / Stream)
  • 桌面环境(GNOME / XFCE / KDE)
  • 想要什么效果(透明 / 阴影 / 性能优化)

我可以给你精准配置方案。

读到这里,发现更多一点。探索更多内容 ↗