温馨提示×

debian compton怎么设置

小樊
36
2026-09-05 00:34:50
栏目: 智能运维

在 Debian 上配置 Compton(现在社区更多用它的继任者 picom,但 Debian 里包名仍常叫 compton)一般用于实现窗口透明、阴影、淡入淡出等合成效果。下面给你一套从安装到常用配置的步骤。


一、安装 Compton

Debian 11 / 12(推荐用 picom,兼容 compton 配置)

sudo apt update
sudo apt install compton

或者安装更活跃的 fork:

sudo apt install picom

如果你用的是 Wayland(如 GNOME/Wayland),Compton 不生效,它只支持 X11。


二、确认你在使用 X11

echo $XDG_SESSION_TYPE

输出应为:

x11

如果是 wayland,请切换回 X11 会话(登录界面选择)。


三、创建配置文件

Compton 默认读取:

~/.config/compton.conf

创建并编辑:

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

四、常用配置示例(适合入门)

基础透明 + 阴影

backend = "glx";
glx-no-stencil = true;

shadow = true;
shadow-radius = 8;
shadow-offset-x = -2;
shadow-offset-y = -2;
shadow-opacity = 0.4;

opacity-rule = [
  "90:class_g = 'URxvt'",
  "95:class_g = 'Firefox'"
];

fade = true;
fade-in-step = 0.03;
fade-out-step = 0.03;

unredir-if-possible = true;

五、启动 Compton

手动启动

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

开机自启(不同桌面环境)

Openbox / i3

~/.config/openbox/autostart 或 i3 配置里加:

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

XFCE

设置 → 会话和启动 → 自启程序 → 添加:

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

六、调试 & 常见问题

1. 透明无效

  • 确保窗口管理器支持 RGBA
  • 终端需支持透明(如 urxvt, alacritty, kitty

2. 画面闪烁

尝试:

backend = "xrender";

3. 视频卡顿

unredir-if-possible = true;

七、Compton vs Picom(建议)

项目 compton picom
维护状态 基本停止 活跃
新特性 blur、rounded
Debian 包 compton picom

如果你想要 毛玻璃模糊

blur-method = "kawase";
blur-strength = 5;

如果你告诉我:

  • 使用的 桌面环境(i3 / Openbox / XFCE / 其他)
  • 是否想要 毛玻璃 / 终端透明 / 阴影

我可以直接给你一份可直接用的配置文件

0