Compton是一个轻量级的X11合成管理器,常用于Linux桌面环境以提供窗口透明、阴影等视觉效果。以下是自定义Compton主题的详细方法:
Compton的配置文件通常位于:
- ~/.config/compton.conf
- ~/.compton.conf
- /etc/xdg/compton.conf
如果不存在,可以创建一个新的配置文件。
以下是常用的自定义选项:
# 启用/禁用合成器
backend = "glx"; # 可选: "xrender"或"glx"
vsync = "opengl-swc"; # 垂直同步
# 窗口透明度设置
inactive-opacity = 0.9;
active-opacity = 1.0;
frame-opacity = 0.7;
inactive-opacity-override = false;
# 阴影设置
shadow = true;
shadow-radius = 12;
shadow-offset-x = -15;
shadow-offset-y = -15;
shadow-opacity = 0.5;
shadow-exclude = [
"name = 'Notification'",
"class_g = 'Conky'",
"class_g ?= 'Notify-osd'",
"class_g = 'Cairo-clock'"
];
# 模糊效果
blur-background = true;
blur-background-frame = true;
blur-background-fixed = true;
blur-kern = "3x3box";
blur-background-exclude = [
"window_type = 'dock'",
"window_type = 'desktop'"
];
# 淡入淡出效果
fading = true;
fade-delta = 5;
fade-in-step = 0.03;
fade-out-step = 0.03;
fade-exclude = [];
可以为特定窗口设置特殊效果:
opacity-rule = [
"90:class_g = 'Terminal'",
"80:class_g = 'Thunar'",
"100:class_g = 'Firefox' && focused",
"85:class_g = 'Firefox' && !focused"
];
要创建不同的主题,可以:
~/.config/compton-light.conf
和~/.config/compton-dark.conf
#!/bin/bash
# 切换compton主题脚本
if [ -f ~/.config/compton-dark.conf ]; then
pkill compton
compton --config ~/.config/compton-dark.conf -b
else
pkill compton
compton --config ~/.config/compton.conf -b
fi
保存配置文件后,重启Compton:
pkill compton
compton --config ~/.config/compton.conf -b
或使用--blah
选项测试而不保存:
compton --blur-background --blur-method kawase --blur-strength 5
wintypes:
{
tooltip = { fade = true; shadow = false; opacity = 0.75; focus = true; };
};
glx-no-stencil = true;
glx-no-rebind-pixmap = true;
xrender-sync-fence = true;
如果遇到问题:
- 检查日志:compton --config ~/.config/compton.conf -b --log-level debug
- 尝试不同的后端(xrender
或glx
)
- 禁用某些功能逐一排查
网上有许多预制的Compton主题可供参考,如: - tryone144的Compton配置 - ibhagwan的picom配置
注意:Compton的新分支名为Picom,配置语法基本兼容但增加了更多功能。
希望这个指南能帮助你自定义理想的Compton主题!