温馨提示×

debian compton配置啥步骤

小樊
52
2026-10-10 19:19:28
栏目: 智能运维

在 Debian 上配置 Compton(现在社区更多用它的继任者 Picom,但命令和配置基本通用)一般分为下面几个步骤:


一、安装 Compton / Picom

1. 更新系统

sudo apt update
sudo apt upgrade

2. 安装

# Compton(旧版)
sudo apt install compton

# 或推荐安装 Picom(新版,兼容 Compton 配置)
sudo apt install picom

二、确认窗口管理器 / 桌面环境

Compton 需要 非合成(non-compositing) 环境才能发挥作用:

  • ✅ 适用:i3、bspwm、Openbox、FVWM 等
  • ❌ 不适用:GNOME、KDE(自带合成器,会冲突)

查看当前会话:

echo $XDG_CURRENT_DESKTOP

三、创建配置文件

1. 创建配置目录

mkdir -p ~/.config/compton

2. 生成示例配置

compton --help
man compton

或直接创建:

nano ~/.config/compton/compton.conf

3. 基础配置示例

# 阴影
shadow = true;
shadow-radius = 12;
shadow-opacity = 0.5;
shadow-offset-x = -2;
shadow-offset-y = -2;

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

# 淡入淡出
fade = true;
fade-delta = 2;

# 后端
backend = "glx";
vsync = true;

# 排除
unredir-if-possible = true;

如果是 picom,配置文件是:

~/.config/picom/picom.conf

四、启动 Compton

1. 手动测试

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

或

picom --config ~/.config/picom/picom.conf

2. 开机自启(以 i3 为例)

在 ~/.config/i3/config 中加入:

exec --no-startup-id compton --config ~/.config/compton/compton.conf

Openbox 在 ~/.config/openbox/autostart:

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

五、常见问题

1. 黑屏 / 卡顿

  • 改用 backend = "xrender"
  • 关闭 vsync

2. 和桌面环境冲突

  • 关闭 GNOME/KDE 自带合成器

3. 高 CPU 占用

  • 减少阴影和透明度规则
  • 使用 glx 后端

如果你告诉我 用的是哪个窗口管理器(i3 / bspwm / Openbox),我可以给你一份可直接用的配置文件。

0 踩