Compton 自定义主题的可行路径
一 核心认知
二 快速上手步骤
sudo apt-get install compton;其他发行版使用各自包管理器安装。cp /etc/compton.conf ~/.config/compton.conf。killall compton; compton -c ~/.config/compton.conf & 重启;若通过会话管理器/自启动脚本管理,则重登或重启会话即可生效。三 主题化配置示例
# 全局渲染与同步
backend = "glx";
vsync = true;
glx-copy-from-front = false;
# 暗色主题
shadow = true;
shadow-radius = 12;
shadow-offset-x = -6;
shadow-offset-y = 6;
shadow-opacity = 0.30;
blur-background = true;
blur-radius = 8;
blur-kern = "3x3box";
background-opacity = 0.95;
# 亮色主题(如需启用,将整段取消注释并注释上面的暗色段)
# shadow = true;
# shadow-radius = 10;
# shadow-offset-x = -5;
# shadow-offset-y = 5;
# shadow-opacity = 0.22;
# blur-background = true;
# blur-radius = 6;
# blur-kern = "3x3box";
# background-opacity = 0.92;
# 按窗口规则排除阴影(示例:Dock、某些面板)
shadow-exclude = [
"class_g = 'Polybar'",
"class_g = 'Conky'",
"name = 'yakuake'"
];
# 可选:窗口规则(更细粒度控制)
opacity-rule = [
"90:class_g = 'URxvt' && !_NET_WM_STATE@:a contains '_NET_WM_STATE_FULLSCREEN'",
"0.85:class_g = 'Firefox' && _NET_WM_STATE@:a contains '_NET_WM_STATE_FULLSCREEN'"
];
四 多主题切换与自启动
export COMPTON_CONFIG=~/.config/compton-dark.conf && comptonnano ~/.config/systemd/user/compton.service[Unit]
Description=Compton Compositor
After=graphical-session.target
[Service]
ExecStart=/usr/bin/compton --config %h/.config/compton-dark.conf
Restart=always
[Install]
WantedBy=graphical-session.target
systemctl --user daemon-reload && systemctl --user enable --now comptonkillall compton; compton -c ~/.config/compton.conf & 快速重启以预览效果。五 常见问题与排错