Compton是一款轻量级窗口合成器,专为Linux桌面设计,通过窗口合成技术提升视觉效果(如阴影、透明度、模糊),同时保持低资源占用,完美兼容Openbox、i3等窗口管理器。对于Ubuntu用户,Compton是优化桌面流畅度的理想工具。
在Ubuntu系统中,通过终端执行以下命令即可安装Compton:
sudo apt-get install compton
安装完成后,Compton会自动集成到系统中,但默认未启用。
Compton的配置文件位于~/.config/compton.conf(若不存在则手动创建)。以下是关键参数设置,兼顾视觉效果与性能:
shadow = false;
false可显著提升性能:opacity = 1.0; # 完全不透明
glx(OpenGL加速)或wayland(现代协议),避免xrender(性能较差):backend = "glx";
true):vsync = true;
ignore_root = true;
bg_blur,但会增加GPU负载,建议在高性能设备上使用:bg_blur = true;
shadow = true;
shadow-exclude = ["class_g 'gnome-terminal'", "class_g 'nautilus'"];
shadow-opacity = 0.3;
shadow-radius = 5;
fps-limit = 60;
glx-no-stencil = true; # 禁用模板缓冲区,提升性能
glx-use-copysubbuffermesa = true; # 优化缓冲区操作
cpulimit工具限制其资源占用(例如限制为50%):cpulimit -l 50 -p $(pgrep compton)
修改配置文件后,通过以下命令重启Compton使更改生效:
killall compton && compton -c ~/.config/compton.conf -f
(-c指定配置文件路径,-f表示前台运行,方便查看日志)。
创建Systemd服务文件/etc/systemd/system/compton.service,内容如下:
[Unit]
Description=Compton Window Composer
After=graphical.target # 确保在图形界面启动后运行
[Service]
ExecStart=/usr/bin/compton --config /home/你的用户名/.config/compton.conf
Restart=on-failure # 失败时自动重启
User=你的用户名
[Install]
WantedBy=multi-user.target
保存后执行以下命令启用并启动服务:
sudo systemctl daemon-reload
sudo systemctl enable compton
sudo systemctl start compton
=两侧是否有空格),或通过compton --config ~/.config/compton.conf --verbose查看详细日志。screen_edge_blur),或升级显卡驱动。vsync(vsync = false),或调整fps-limit值。通过以上步骤,你可根据Ubuntu设备的硬件配置(如CPU、GPU性能)和个人偏好,调整Compton参数,打造流畅且美观的桌面体验。记得根据实际效果灵活调整,优先保证性能再追求视觉效果。