根据不同的Linux发行版,使用相应的包管理器进行安装:
sudo apt update,sudo apt install compton。sudo dnf install compton(CentOS需先启用EPEL仓库)。sudo pacman -S compton。git clone https://github.com/compton-compositor/compton.git,进入目录后mkdir build && cd build,cmake ..,make,sudo make install。创建或编辑配置文件~/.config/compton.conf:
backend:选择渲染后端,如glx或wayland。shadow-exclude:排除不需要阴影的窗口,如shadow-exclude = [ "class_g = 'Firefox'" ]。opacity-rule:设置窗口透明度规则,如opacity-rule = [ "class_g = 'Gtk' window_opacity = 0.9" ]。fade:启用或禁用淡入淡出效果。vsync:启用或禁用垂直同步。backend = "glx";
shadow-exclude = "*.menu,*.notification";
fade = true;
opacity-rule = [ "class_g = 'Firefox' window_opacity = 0.9" ];
compton。/etc/systemd/system/compton.service,内容如下:[Unit]
Description=Compton Compositor
After=display-manager.service
[Service]
ExecStart=/usr/local/bin/compton --config ~/.config/compton.conf
Restart=always
[Install]
WantedBy=multi-user.target
然后执行sudo systemctl enable compton和sudo systemctl start compton。