一、安装Compton
Compton是一款轻量级窗口合成器,需先通过包管理器安装。根据发行版选择对应命令:
sudo apt-get install compton
sudo dnf install compton
sudo pacman -S compton
二、配置Compton以提升显示效果
Compton的配置文件通常位于~/.config/compton.conf
(若不存在则手动创建)。以下是关键配置选项及说明:
bg_blur true
,使窗口后方区域呈现模糊效果,增强层次感。shadow true
,为窗口边缘添加阴影,提升立体感和视觉深度。screen_edge_blur true
,让屏幕边缘区域产生模糊效果,模拟“无限桌面”的视觉感受。opacity
参数设置全局透明度(如opacity 0.8
表示80%不透明度);或使用opacity-rule
针对特定应用调整(例如opacity-rule ["90:class_g 'Firefox'", "100:class_g 'Xephyr'"]
,Firefox窗口透明度为90%,Xephyr窗口保持不透明)。vsync true
,同步画面刷新率与显示器刷新率,减少画面撕裂现象。ignore_glx_glitz true
,禁用OpenGL加速。三、性能优化技巧
为避免Compton占用过多系统资源(尤其是低配置设备),可通过以下方式优化:
backend
设置为glx
(适用于大多数现代显卡)或wayland
(若系统支持),替代默认的xrender
,显著提升渲染性能。shadow
设为false
、bg_blur
设为false
,减少GPU负载。vsync
——若开启后出现卡顿,可尝试设为false
。backend glx
可充分利用GPU资源,提升Compton运行效率。cpulimit
工具限制Compton的CPU占用率(例如cpulimit -l 50 -p $(pgrep compton)
,将CPU使用率限制在50%),避免影响系统整体性能。四、启动与自动运行
重启Compton应用配置:修改配置文件后,需重启Compton使更改生效。可使用以下命令:
killall compton && compton --config ~/.config/compton.conf &
或通过systemctl
(若使用systemd服务):
sudo systemctl restart compton
设置开机自动启动:
/etc/systemd/system/compton.service
,内容如下:[Unit]
Description=Compton Window Composer
After=xorg.service
[Service]
ExecStart=/usr/bin/compton --config /etc/compton.conf
RestartOnFailure=yes
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable compton
sudo systemctl start compton
注意事项