在 CentOS 上配置 Compton(一个用于 OpenGL 合成的 Compositor)可以让你更好地管理窗口的显示效果,比如阴影、透明度等。以下是详细的步骤指南:
首先,你需要安装 Compton。你可以使用 yum
或者 dnf
来安装。
sudo yum install epel-release
sudo yum install compton
或者使用 dnf
:
sudo dnf install compton
Compton 的配置文件通常位于 /etc/compton.conf
,但你可以创建自己的配置文件并指定路径。
你可以创建一个新的配置文件,例如 ~/.compton.conf
,并在其中添加你的配置选项。以下是一个基本的配置示例:
backend = "glx";
shadow-exclude = [ "WINDOW_CLASS=.*Firefox" ];
glx-no-stencil = true;
glx-damage = false;
你可以手动启动 Compton 并指定配置文件路径:
compton --config ~/.compton.conf
为了让 Compton 在系统启动时自动运行,你可以将其添加到你的桌面环境的启动脚本中。
如果你使用的是 GNOME,可以使用 gnome-shell-extension-prefs
来管理扩展。你可以创建一个自定义的 GNOME Shell 扩展来启动 Compton。
创建一个新的扩展目录:
mkdir -p ~/.local/share/gnome-shell/extensions/compton@yourusername
cd ~/.local/share/gnome-shell/extensions/compton@yourusername
创建 extension.js
文件:
const Gio = imports.gi.Gio;
const Main = imports.ui.main;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
let _indicator;
function init() {}
function enable() {
_indicator = new St.Bin({
style_class: 'panel-button',
reactive: true,
can_focus: true,
x_fill: true,
y_fill: false,
track_hover: true,
});
let icon = new St.Icon({ icon_name: 'system-run-symbolic', style_class: 'system-status-icon' });
_indicator.add(icon);
_indicator.connect('button-press-event', Lang.bind(this, function() {
Main.wm.addCompositor('compton', {
config: '~/.compton.conf'
});
}));
Main.panel._rightBox.pack_start(_indicator, false, false, 0);
_indicator.show();
}
function disable() {
if (_indicator) {
_indicator.destroy();
_indicator = null;
}
}
创建 metadata.json
文件:
{
"uuid": "compton@yourusername",
"name": "Compton",
"description": "Compositor using OpenGL",
"shell-version": ["3.36", "3.38", "40", "42"]
}
启用扩展:
打开 GNOME Tweak Tool,导航到 Extensions 部分,找到并启用你的 Compton 扩展。
如果你使用的是 KDE Plasma,可以使用 kstart
来启动 Compton。
创建一个 kstart
脚本:
mkdir -p ~/.config/autostart
nano ~/.config/autostart/compton.desktop
添加以下内容:
[Desktop Entry]
Type=Application
Exec=compton --config ~/.compton.conf
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=Compton
保存并退出。
如果你遇到问题,可以查看 Compton 的日志输出:
compton --config ~/.compton.conf --log-level debug
这将帮助你诊断配置中的问题。
通过以上步骤,你应该能够在 CentOS 上成功配置并运行 Compton。