在 Linux 中,Compton(现在多被分支 picom 取代)可以通过配置文件实现窗口/桌面透明效果。下面以常见用法说明。
# Debian / Ubuntu
sudo apt install compton
# 或使用 picom(推荐)
sudo apt install picom
# Arch
sudo pacman -S picom
配置文件一般位于:
~/.config/compton.conf
# 或
~/.config/picom.conf
示例配置(基础透明):
# 开启透明
opacity-rule = [
"90:class_g = 'URxvt'",
"85:class_g = 'Firefox'",
"80:class_g = 'Thunar'"
];
# 全局窗口透明度(0.0~1.0)
inactive-opacity = 0.9;
active-opacity = 1.0;
# 桌面背景是否透明
frame-opacity = 1.0;
# 阴影(可选)
shadow = true;
shadow-opacity = 0.5;
# 后端
backend = "glx";
inactive-opacity = 0.8;
非当前窗口变透明。
opacity-rule = [
"80:class_g = 'Alacritty'",
"70:class_g = 'Chromium'"
];
数值越小越透明(80 = 80% 不透明)。
终端自身也需开启透明:
Alacritty
background_opacity: 0.8
Kitty
background_opacity 0.8
确保你的窗口管理器支持 compositor,并启动:
compton &
# 或
picom &
compton --config ~/.config/compton.conf &
或加入自启(i3 示例):
exec --no-startup-id compton
✅ 透明无效?
picom 替代 comptonbackend = "glx" 或 "xrender"✅ 全屏视频闪?
unredirect-if-possible = true;
如果你告诉我:
我可以给你一份精准配置。