在 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。