一、安装Compton
在Ubuntu系统上,Compton可以通过官方软件源直接安装。打开终端,执行以下命令:
sudo apt-get update && sudo apt-get install compton
安装完成后,Compton会默认安装在/usr/bin/目录下。
二、配置Compton
Compton的配置文件通常位于用户主目录的.config文件夹下(路径:~/.config/compton.conf)。若文件不存在,可通过以下命令创建:
mkdir -p ~/.config && nano ~/.config/compton.conf
使用文本编辑器(如nano)打开配置文件后,可根据需求调整以下关键参数:
glx(需显卡支持OpenGL),性能优于xrender;若遇到兼容性问题(如窗口闪烁),可切换为xrender。backend = "glx";
true(推荐)或false(适合低性能设备)。vsync = "true";
shadow-radius(阴影半径)、shadow-opacity(阴影透明度)等子参数。shadow = "false"; # 关闭阴影以提升性能
# 若开启,可调整为:
# shadow = "true";
# shadow-radius = 8;
# shadow-opacity = 0.3;
0.8(80%不透明度)或直接关闭(opacity = "false")。opacity = "0.8"; # 80%不透明度
# 若完全关闭透明度:
# opacity = "false";
blur-method(模糊算法,如gaussian)使用。bg_blur = "true";
blur-method = "gaussian";
blur-strength = 10; # 模糊强度(1-20,数值越大越模糊)
screen_edge_blur = "true";
edge-blur-strength = 5; # 边缘模糊强度
fade = "true";
fade-delta = 10; # 动画速度(数值越小,动画越快)
ignore_root = "true";
ignore_glx_glitz = "true";
三、启动Compton
配置完成后,需重启Compton使更改生效。可通过以下命令重启:
killall compton && compton -b --config ~/.config/compton.conf
其中,-b表示Compton在后台运行(作为守护进程),--config指定自定义配置文件路径。
四、优化建议
cpulimit工具限制其CPU占用率(例如限制为50%):cpulimit -l 50 -p $(pgrep compton)
top、htop等工具监控Compton的资源占用情况,及时调整配置参数。通过以上步骤,可根据自身硬件配置与视觉需求,优化Ubuntu系统的显示效果与性能。