Compton是一款轻量级的X11合成窗口管理器,能够为Linux桌面提供窗口透明、阴影、淡入淡出等视觉效果。以下是详细的安装与配置指南。
# Debian/Ubuntu及其衍生版
sudo apt install compton
# Arch Linux/Manjaro
sudo pacman -S compton
# Fedora
sudo dnf install compton
# openSUSE
sudo zypper install compton
# Gentoo
sudo emerge --ask x11-misc/compton
# 安装依赖
sudo apt install libx11-dev libxcomposite-dev libxdamage-dev libxfixes-dev \
libxext-dev libxrender-dev libxrandr-dev libdbus-1-dev libconfig-dev \
libdrm-dev libgl-dev libpcre3-dev libev-dev uthash-dev libx11-xcb-dev \
meson ninja-build
# 克隆仓库
git clone https://github.com/yshui/compton.git
cd compton
# 编译安装
meson --buildtype=release . build
ninja -C build
sudo ninja -C build install
mkdir -p ~/.config/compton
nano ~/.config/compton/compton.conf
# 基本设置
backend = "glx";
vsync = "opengl-swc";
# 窗口透明效果
opacity-rule = [
"90:class_g = 'URxvt'",
"85:class_g = 'Termite'",
"80:class_g = 'Alacritty'"
];
# 窗口阴影
shadow = true;
shadow-radius = 12;
shadow-offset-x = -5;
shadow-offset-y = -5;
shadow-opacity = 0.5;
shadow-exclude = [
"name = 'Notification'",
"class_g = 'Conky'",
"class_g ?= 'Notify-osd'",
"class_g = 'Cairo-clock'"
];
# 淡入淡出效果
fading = true;
fade-delta = 5;
fade-in-step = 0.03;
fade-out-step = 0.03;
compton --config ~/.config/compton/compton.conf -b
echo 'compton --config ~/.config/compton/compton.conf -b &' >> ~/.xinitrc
# 在配置文件中添加
vsync = "opengl";
glx-swap-method = "buffer-age";
# 使用更轻量的后端
backend = "xrender";
# 禁用某些特效
shadow = false;
fading = false;
# 排除特定程序
shadow-exclude = [
"class_g = 'Firefox' && argb",
"class_g = 'Chromium' && argb"
];
[monitor=HDMI-0]
shadow = true;
shadow-radius = 10;
[monitor=eDP-1]
shadow = false;
# 切换Compton开关
bindkey = "Mod4+Shift+t";
command = "pkill -USR1 compton";
Compton已停止维护,其分支Picom是活跃开发版本。如需最新功能可考虑切换:
sudo apt install picom # 或使用发行版对应的包名
希望本指南能帮助您顺利安装配置Compton,为您的Linux桌面增添美观的视觉效果!