温馨提示×

ubuntu compton怎么配置

小樊
54
2026-09-01 04:28:12
栏目: 智能运维

在 Ubuntu 上配置 Compton(现在多称为 picom,Compton 的活跃分支),通常用于为无原生混成的窗口管理器(如 i3、Openbox、Awesome 等)提供窗口透明、阴影、模糊等特效。

下面从 安装 → 基础配置 → 常用参数 → 开机启动 一步步说明。


一、安装 Compton / picom

1. 使用系统仓库(推荐新手)

sudo apt update
sudo apt install compton

或使用更活跃的 fork:

sudo apt install picom

注意:Ubuntu 20.04+ 以后,picom 通常是 Compton 的替代品


二、生成配置文件

Compton 默认读取:

~/.config/compton.conf

如果不存在,可以手动创建:

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

三、基础配置示例(常用)

下面是一个 通用且稳定 的 compton.conf 示例:

# 后台运行
daemon = true;

# 阴影
shadow = true;
shadow-radius = 8;
shadow-opacity = 0.5;
shadow-offset-x = -2;
shadow-offset-y = -2;
shadow-exclude = [
  "name = 'Notification'",
  "class_g = 'Conky'",
  "class_g = 'Dmenu'"
];

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

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

# 垂直同步
vsync = true;

# 后端(性能更好)
backend = "glx";

# 排除全屏应用(看视频更流畅)
unredir-if-possible = true;

四、启动 Compton

手动启动

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

或(picom):

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

五、开机自动启动

如果你用 i3

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

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

如果用 Openbox

在 ~/.config/openbox/autostart 中:

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

通用方式(systemd 用户服务,可选)

systemctl --user enable compton

六、常见问题

1. 透明不生效?

  • 窗口管理器需支持 RGBA
  • 终端要开启透明(如 URxvt、Alacritty)

2. 卡顿 / 闪屏?

尝试:

backend = "xrender";
vsync = false;

3. Ubuntu 默认用 GNOME?

GNOME 已有 Mutter,不需要 Compton


七、推荐场景

✅ i3 / bspwm / dwm / openbox
❌ GNOME / KDE(自带混成)


如果你告诉我:

  • Ubuntu 版本
  • 窗口管理器(i3?awesome?)
  • 想要透明 / 模糊 / 阴影?

我可以给你一份 专属配置。

0 踩