一、安装Compton
首先需根据Linux发行版安装Compton,常用命令如下:
sudo apt-get install comptonsudo dnf install comptonsudo pacman -S compton二、配置文件位置
Compton的默认配置文件通常位于~/.config/compton.conf(用户级)或/etc/xdg/compton.conf(系统级)。若文件不存在,可通过touch ~/.config/compton.conf创建,再用文本编辑器(如nano)编辑。
三、常用显示效果配置选项
bg_blur true,并可选调整模糊参数(如blur-method gaussian、blur-size 10、blur-deviation 5.0),增强桌面层次感。shadow true,并通过shadow-radius(阴影半径,默认5)、shadow-offset-x/y(阴影偏移量,默认±1)、shadow-opacity(阴影透明度,默认0.3)调整阴影效果,避免过度遮挡窗口内容。screen_edge_blur true,使屏幕边缘区域呈现模糊效果,提升视觉沉浸感。opacity 0.8(0.0-1.0之间,1.0为不透明),可配合alpha-threshold(透明度阈值,默认0.5)定义完全透明的窗口阈值,实现窗口半透明效果。vsync true,同步屏幕刷新率与显卡输出,减少画面撕裂;若出现卡顿,可尝试设置为false。四、性能优化配置
backend设置为glx(支持OpenGL加速,性能最佳)或wayland(适用于Wayland环境),避免使用xrender(性能较差)。shadow false、bg_blur false,减少GPU/CPU负载。vsync设置为false或调整refresh-rate参数,避免Compton成为性能瓶颈。backend glx会自动启用GPU加速;若仍存在性能问题,可检查显卡驱动是否支持OpenGL 3.3及以上版本。cpulimit工具限制Compton的CPU使用率(如cpulimit -l 50 -p $(pgrep compton)),避免Compton占用过多系统资源。五、重启Compton应用配置
修改配置文件后,需重启Compton使更改生效。常用命令:
killall compton && compton &compton --config ~/.config/my-custom-compton.conf -f。