Compton是一个轻量级的X11合成窗口管理器,用于提供窗口透明、阴影、淡入淡出等视觉效果。以下是Compton的详细设置方法:
sudo apt install compton
sudo pacman -S compton
sudo dnf install compton
Compton的配置文件通常位于~/.config/compton.conf
或~/.compton.conf
。如果不存在,可以创建一个。
mkdir -p ~/.config
touch ~/.config/compton.conf
# 基本设置
backend = "glx";
paint-on-overlay = true;
glx-no-stencil = true;
glx-no-rebind-pixmap = true;
vsync = "opengl-swc";
# 阴影设置
shadow = true;
no-dock-shadow = true;
no-dnd-shadow = true;
shadow-radius = 7;
shadow-offset-x = -7;
shadow-offset-y = -7;
shadow-opacity = 0.7;
shadow-red = 0.0;
shadow-green = 0.0;
shadow-blue = 0.0;
shadow-exclude = [
"name = 'Notification'",
"class_g = 'Conky'",
"class_g ?= 'Notify-osd'",
"class_g = 'Cairo-clock'",
"_GTK_FRAME_EXTENTS@:c"
];
# 淡入淡出效果
fading = true;
fade-delta = 4;
fade-in-step = 0.03;
fade-out-step = 0.03;
fade-exclude = [ ];
# 透明度设置
inactive-opacity = 0.8;
active-opacity = 1.0;
frame-opacity = 0.7;
inactive-opacity-override = false;
opacity-rule = [
"90:class_g = 'Alacritty'",
"80:class_g = 'URxvt'"
];
# 其他设置
detect-rounded-corners = true;
detect-client-opacity = true;
refresh-rate = 0;
dbe = false;
unredir-if-possible = true;
focus-exclude = [ "class_g = 'Cairo-clock'" ];
mark-wmwin-focused = true;
mark-ovredir-focused = true;
detect-transient = true;
detect-client-leader = true;
use-ewmh-active-win = true;
invert-color-include = [ ];
# 窗口类型设置
wintypes:
{
tooltip = { fade = true; shadow = true; opacity = 0.75; focus = true; };
};
compton --config ~/.config/compton.conf -b
将以下内容添加到你的窗口管理器或桌面环境的启动脚本中:
对于~/.xinitrc:
compton --config ~/.config/compton.conf -b &
对于i3wm (添加到~/.config/i3/config):
exec --no-startup-id compton --config ~/.config/compton.conf -b
-b
: 作为后台守护进程运行--config <path>
: 指定配置文件路径--backend <backend>
: 指定后端(glx,xrender等)--vsync <method>
: 设置垂直同步方法--shadow-exclude <pattern>
: 排除特定窗口的阴影--opacity-rule <rule>
: 设置特定窗口的透明度规则opacity-rule = [
"0:_NET_WM_STATE@:32a *= '_NET_WM_STATE_HIDDEN'",
"95:class_g = 'Firefox' && !_NET_WM_STATE@:32a",
"0:class_g = 'Dunst'"
];
# 使用更快的后端
backend = "xrender";
# 禁用某些检测以提升性能
detect-rounded-corners = false;
detect-client-opacity = false;
# 减少重绘
paint-on-overlay = true;
glx-no-stencil = true;
glx-no-rebind-pixmap = true;
# 为每个显示器单独设置
shadow-exclude = [
"output = 'HDMI-0'",
"output = 'DP-1'"
];
尝试不同的vsync方法:
vsync = "opengl"; # 或 "opengl-swc", "opengl-oml", "xpresent"
尝试使用xrender后端:
backend = "xrender";
将该应用程序添加到排除列表中:
shadow-exclude = [
"class_g = 'ProblematicApp'"
];
通过以上配置,你可以根据个人喜好调整Compton的视觉效果,同时平衡性能和美观。