Linux Compton配置中设置主题和皮肤的方法
Compton本身是一个轻量级窗口合成器,不直接支持传统意义上的“主题”或“皮肤”自定义(如Windows下的主题包或Mac的皮肤引擎)。其视觉效果主要通过配置文件调整参数实现,如阴影、模糊、透明度等。若需更丰富的主题效果,可通过第三方工具或组合其他工具间接实现。
Compton的主题风格主要由配置文件中的参数决定,默认配置文件路径为~/.config/compton.conf(若不存在可手动创建)。以下是常用参数及说明:
shadow = true:启用窗口阴影(默认关闭)。shadow-radius = 12:阴影圆角半径(数值越大越柔和)。shadow-offset-x = -15/shadow-offset-y = -15:阴影偏移量(负值表示向窗口左上方偏移)。shadow-opacity = 0.5:阴影透明度(0~1,值越小越淡)。shadow-exclude:排除不需要阴影的窗口(如通知栏、桌面图标),格式为数组,例如:shadow-exclude = ["name = 'Notification'", "class_g = 'Conky'", "class_g ?= 'Notify-osd'"];
blur-background = true:启用背景模糊(需GPU支持)。blur-background-frame = true:模糊窗口框架。blur-background-fixed = true:固定模糊效果(不随窗口移动更新)。blur-kern = "3x3box":模糊算法(如"3x3box"、“5x5gaussian”,数值越大越模糊)。blur-background-exclude:排除不需要模糊的窗口(如dock、桌面),例如:blur-background-exclude = ["window_type = 'dock'", "window_type = 'desktop'"];
inactive-opacity = 0.9:非活动窗口的透明度(0~1)。active-opacity = 1.0:活动窗口的透明度。frame-opacity = 0.7:窗口边框的透明度。background-opacity = 1.0:背景的透明度(1.0为不透明)。fading = true:启用淡入淡出动画。fade-delta = 5:动画速度(数值越小越快)。fade-in-step = 0.03/fade-out-step = 0.03:淡入/淡出的步进值(控制动画平滑度)。若需更丰富的主题效果(如自定义颜色、图标),需结合其他工具间接实现:
Compton的视觉效果受GTK主题影响(如窗口边框、颜色)。可通过安装GTK主题工具(如Arc Theme、Numix)并修改其配置,间接改变Compton的视觉风格:
sudo apt install arc-theme
Debian及其衍生发行版(如Ubuntu)可使用compton-theme-gtk2工具,通过修改配置文件实现更详细的主题定制:
sudo apt install compton-theme-gtk2
~/.config/compton-dark.conf),设置颜色、边框等参数:background-color #1e1e1e; # 背景色
foreground-color #d4d4d4; # 前景色(窗口边框)
border-color #4e4e4e; # 边框颜色
border-width 1px; # 边框宽度
border-radius 6px; # 边框圆角
shadow-exponent 3; # 阴影指数(控制阴影扩散范围)
use-shadow true; # 启用阴影
COMPTON_CONFIG指向对应的配置文件,例如在~/.xprofile中添加:export COMPTON_CONFIG=~/.config/compton-dark.conf
Ctrl+O保存,Ctrl+X退出文本编辑器。pkill compton && compton -c ~/.config/compton.conf &
若使用systemd管理Compton,需重启服务:systemctl --user restart compton