1. 安装Compton
在Debian系统上,首先通过以下命令更新软件包列表并安装Compton:
sudo apt update && sudo apt upgrade -y
sudo apt install compton x11-xserver-utils wmctrl -y
x11-xserver-utils和wmctrl是Compton运行所需的依赖项,确保系统兼容性。
2. 配置Compton
Compton的默认配置文件位于~/.config/compton.conf(若不存在则手动创建)。使用文本编辑器(如nano)打开配置文件,根据需求调整以下核心参数:
glx(OpenGL加速)或wayland(适用于Wayland会话),替代传统的xrender,可显著提升合成性能。backend = "glx"
shadow-exclude排除不需要阴影的窗口(如GTK应用、对话框),减少性能开销;若无需阴影,直接禁用shadow。shadow = false
shadow-exclude = ["class_g 'GtkWindow'", "class_g 'GtkDialog'"]
opacity(设为false),避免不必要的合成计算。opacity = false
vsync可防止屏幕撕裂,但可能增加输入延迟,根据显示器性能调整(建议笔记本或高刷新率显示器开启)。vsync = true
3. 启动Compton
配置完成后,通过命令行启动Compton并指定配置文件:
compton --config ~/.config/compton.conf &
若需验证Compton是否运行,可使用ps aux | grep compton查看进程。
4. 设置开机自启动
为避免每次登录手动启动Compton,可创建systemd服务文件:
sudo nano /etc/systemd/system/compton.service
添加以下内容(替换你的用户名为实际用户名):
[Unit]
Description=Compton Compositor
After=display-manager.service
[Service]
ExecStart=/usr/bin/compton --config ~/.config/compton.conf
Restart=always
User=你的用户名
[Install]
WantedBy=multi-user.target
保存后,启用并启动服务:
sudo systemctl enable compton
sudo systemctl start compton
5. 性能优化技巧
fade(窗口淡入淡出)、blur(背景模糊)等特效,进一步降低CPU/GPU负载。cpulimit工具限制Compton的CPU占用(如限制为50%),避免影响系统整体性能:cpulimit -l 50 -p $(pgrep compton)
compton-conf),根据自身硬件和桌面环境调整参数。6. 测试与验证
启动Compton后,通过以下方式验证配置效果:
htop或glances监控系统资源占用,确保Compton未导致CPU/GPU过载;