Debian系统中Compton安装步骤
在安装Compton前,需确保系统已连接互联网且具备管理员权限(sudo)。若使用NVIDIA显卡,建议提前安装官方闭源驱动以提升兼容性。
APT是Debian默认的包管理工具,操作简便且能自动处理依赖关系,适合大多数用户。
sudo apt update
sudo apt install compton
compton --version
若官方仓库的Compton版本过旧,可通过源码编译安装最新版,但过程较复杂。
sudo apt install build-essential cmake git libx11-dev libxcb-xinerama0-dev libxcb-render-util0-dev libxcb-shm0-dev libxcb-randr0-dev libxcb-glx0-dev libxcb-keysyms1-dev libxcb-image0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-util-dev
git clone https://github.com/compton-compositor/compton.git
cd compton
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j$(nproc) # 使用多核加速编译
sudo make install # 安装至系统目录
Compton的配置文件用于调整窗口特效、透明度、阴影等参数,支持用户个性化设置。
sudo nano /etc/compton.conf
mkdir -p ~/.config
touch ~/.config/compton.conf
nano ~/.config/compton.conf
# 渲染后端:glx(性能好,需显卡支持)或xrender(兼容性好)
backend = "glx"
# 开启窗口阴影(true/false)
shadow = true
# 阴影排除规则(避免桌面图标、面板等产生阴影)
shadow-exclude = [
"class_g = 'GtkWindow'",
"class_i = 'GtkDialog'",
"instance_g = 'Firefox'"
]
# 窗口透明度(0.0~1.0,1.0为不透明)
opacity = 0.8
# 启用垂直同步(减少画面撕裂,true/false)
vsync = true
Ctrl+O保存文件,Ctrl+X退出编辑器。安装完成后,可通过以下命令手动启动Compton:
compton --config ~/.config/compton.conf # 使用用户级配置
# 或
compton --config /etc/compton.conf # 使用全局配置
若配置文件路径正确,Compton将自动应用设置并启动。
若希望Compton随系统启动自动运行,需创建systemd服务文件。
sudo nano /etc/systemd/system/compton.service
your_username替换为实际用户名):[Unit]
Description=Compton Window Composer
After=graphical.target
[Service]
ExecStart=/usr/bin/compton --config ~/.config/compton.conf
Restart=on-failure
User=your_username
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload # 重新加载systemd配置
sudo systemctl enable compton # 设置开机自启
sudo systemctl start compton # 立即启动服务
sudo systemctl status compton # 查看服务是否运行正常
```。