温馨提示×

Compton配置如何生效

小樊
42
2026-08-06 04:52:11
栏目: 编程语言

要让 Compton(现在多被 picom 取代)的配置生效,核心流程是:修改配置文件 → 重启 Compton/picom。下面按常见场景详细说明。


一、确认你用的是 Compton 还是 picom

很多发行版已经用 picom 替代 Compton:

which compton picom
  • picom → 用 picom
  • 只有 compton → 用 compton(较老)

下面以 picom 为主说明,compton 基本通用。


二、配置文件位置(最重要)

1️⃣ 默认读取顺序(picom)

picom 会按以下顺序查找配置(找到第一个就停):

~/.config/picom/picom.conf
~/.config/picom.conf
/etc/xdg/picom.conf

推荐路径

~/.config/picom/picom.conf

如果是 compton:

~/.config/compton.conf

三、创建 / 修改配置文件

示例最小配置

# ~/.config/picom/picom.conf
backend = "glx";
vsync = true;

shadow = true;
shadow-radius = 12;
shadow-offset-x = -15;
shadow-offset-y = -15;

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

opacity-rule = [
  "90:class_g = 'Alacritty'",
  "80:class_g = 'Firefox'"
];

修改后保存。


四、让配置生效(关键步骤)

✅ 方法 1:重启 picom(最常用)

killall picom
picom --daemon

或(老系统):

killall compton
compton --daemon

✅ 方法 2:指定配置文件启动(调试时推荐)

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

如果配置有错误,终端会直接提示。


五、开机自动生效

1️⃣ 在 ~/.xinitrc

picom --daemon &

2️⃣ 在 i3 / bspwm / openbox 配置中

exec --no-startup-id picom --daemon

六、常见不生效原因排查

❌ 1. 配置文件路径不对

picom --help | grep config

如果没读取到,会提示默认配置。


❌ 2. 配置语法错误

  • 少了分号 ;
  • 括号不匹配
  • 使用了过时参数

✅ 检查:

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

❌ 3. 多个 picom 实例冲突

ps aux | grep picom

确保只有一个。


❌ 4. Wayland 下不生效

⚠️ Compton / picom 只支持 X11

echo $XDG_SESSION_TYPE

如果是 wayland,需要换合成器(如 sway 自带)。


七、快速自检清单 ✅

  • [ ] 使用 X11
  • [ ] 配置文件在 ~/.config/picom/picom.conf
  • [ ] 语法正确
  • [ ] 重启 picom
  • [ ] 没有多个实例

如果你愿意,可以把你的 发行版 + 桌面环境 / WM + picom 版本 发给我,我可以帮你精确排查。

0