插件窝 干货文章 Compton在Linux中的安装步骤

Compton在Linux中的安装步骤

Compton sudo bash config 464    来源:    2025-05-09

在Linux系统中安装Compton(一个轻量级的X11合成器,常用于窗口透明、阴影等视觉效果)的步骤如下,分为不同发行版的安装方式以及基础配置指南:


1. 安装Compton

Ubuntu/Debian系

sudo apt update
sudo apt install compton

注意:部分新版本系统可能已用picom替代compton,若需最新特性可安装picom

sudo apt install picom

Arch Linux/Manjaro

sudo pacman -S compton
# 或使用社区增强版picom
sudo pacman -S picom

Fedora/RHEL系

sudo dnf install compton

从源码编译(通用)

若需最新版本或定制功能:

git clone https://github.com/yshui/compton.git
cd compton
make
sudo make install

依赖项需提前安装(如libx11-devlibxcomposite-dev等)。


2. 基本配置

生成默认配置文件

mkdir -p ~/.config/compton
compton --example-config > ~/.config/compton/compton.conf

常用配置选项

编辑~/.config/compton/compton.conf

# 启用阴影
shadow = true;
# 透明度设置(需配合窗口管理器如i3)
inactive-opacity = 0.8;
active-opacity = 1.0;
# 模糊背景(需支持)
blur-background = true;

3. 启动Compton

手动启动

compton --config ~/.config/compton/compton.conf -b
  • -b:后台运行。

自动启动

  • 方法1:添加到桌面环境(如KDE/GNOME)的“自动启动程序”。
  • 方法2:在窗口管理器(如i3/sway)的配置文件中添加: bash exec --no-startup-id compton --config ~/.config/compton/compton.conf -b

4. 常见问题解决

黑屏/无效果

  • 检查是否与其他合成器(如GNOME的Mutter)冲突,关闭后者。
  • 尝试禁用GPU加速: bash compton --backend glx --vsync opengl-swc

性能问题

  • 使用更轻量后端: bash compton --backend xrender
  • 减少阴影或模糊强度。

版本兼容性

  • 若系统默认版本较旧,建议使用picom(Compton的分支,持续维护): bash sudo apt install picom # Ubuntu sudo pacman -S picom # Arch

5. 卸载Compton

sudo apt remove compton    # Debian/Ubuntu
sudo pacman -R compton    # Arch
sudo dnf remove compton   # Fedora

通过以上步骤,您应能顺利安装并配置Compton。如需更高级功能(如动画、规则匹配),可参考官方文档或社区教程。