温馨提示×

linux compton如何开启

小樊
45
2026-10-18 10:52:06
栏目: 智能运维

在 Linux 中,Compton 是一个轻量级的 X11 合成管理器(用于窗口透明、阴影、模糊等效果)。下面按常见场景说明如何“开启”它。


一、确认环境(重要)

Compton 只适用于 X11,不适用于纯 Wayland。

查看当前会话:

echo $XDG_SESSION_TYPE
  • 显示 x11 → 可以继续
  • 显示 wayland → Compton 不可用(可考虑 picom)

二、安装 Compton

Debian / Ubuntu

sudo apt update
sudo apt install compton

Arch / Manjaro

sudo pacman -S compton

Fedora

sudo dnf install compton

三、启动 Compton

1️⃣ 手动启动(测试用)

compton &

如果没报错,透明/阴影通常立即生效。


2️⃣ 开机自动启动

方法 A:桌面环境自启动(推荐)

  • GNOME / KDE / XFCE:
    • 打开「启动应用程序」
    • 添加命令:compton

方法 B:.xinitrc(使用 startx)

在 ~/.xinitrc 中加入:

compton &
exec dwm   # 或 i3 / openbox 等

方法 C:i3 / bspwm 等窗口管理器

在配置文件里加:

exec compton

四、基本配置文件(可选)

创建:

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

示例:

backend = "glx";
shadow = true;
fade = true;
opacity-rule = [
  "90:class_g = 'URxvt'"
];

启动指定配置:

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

五、常见问题

❌ 透明无效

  • 确认窗口管理器支持 compositing
  • 使用 glx 后端:
compton --backend glx

❌ 高 CPU 占用

关闭阴影或模糊:

shadow = false;
blur-background = false;

六、Compton 已停止维护?

Compton 已基本停止更新,社区推荐使用 picom(兼容 Compton 配置):

sudo apt install picom
picom &

如果你告诉我:

  • 发行版
  • 桌面环境 / 窗口管理器
  • 是否使用 NVIDIA

我可以给你更精确的开启方式。

0 踩