温馨提示×

ubuntu compton怎样配置

小樊
40
2026-10-27 16:55:31
栏目: 智能运维

在 Ubuntu 上配置 Compton(现已多被 picom 取代,但配置方式基本一致)通常用于实现窗口透明、阴影、模糊等合成效果。下面从安装 → 配置 → 启动一步步说明。


一、安装 Compton / Picom

1. 安装 compton(旧版)

sudo apt update
sudo apt install compton

2. 推荐:安装 picom(compton 的维护分支)

sudo apt install picom

以下示例以 picom 为例,如果你用 compton,只需把命令中的 picom 换成 compton。


二、创建配置文件

默认配置文件位置:

~/.config/picom/picom.conf

如果没有就创建:

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

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

编辑配置文件:

nano ~/.config/picom/picom.conf

最小可用配置

backend = "glx";
vsync = true;

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

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

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

四、透明 & 模糊配置(常用效果)

窗口透明

inactive-opacity = 0.9;
active-opacity = 1.0;

背景模糊(需要 glx backend)

blur:
{
  method = "gaussian";
  size = 10;
  deviation = 5.0;
}

五、启动 Picom / Compton

手动启动

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

或

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

六、开机自启(Ubuntu + 桌面环境)

GNOME / Unity

mkdir -p ~/.config/autostart

创建文件:

nano ~/.config/autostart/picom.desktop

内容:

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

七、常见问题

1. 黑屏 / 卡顿

  • 尝试切换 backend:
backend = "xrender";

2. 与桌面合成冲突

  • 关闭系统自带合成(如 GNOME 的 Mutter)
  • 或使用 picom --replace

3. 无法使用模糊

  • 确认驱动支持 OpenGL
  • backend = "glx"

八、调试命令

picom --config ~/.config/picom/picom.conf --log-level DEBUG

如果你用的是 Ubuntu 版本 + 桌面环境(GNOME / KDE / i3 / XFCE),可以告诉我,我可以给你更精确的配置方案。

0 踩