溫馨提示×

怎樣在centos配置compton

小樊
41
2025-04-06 20:48:10
欄目: 智能運維

在 CentOS 上配置 Compton(一個用于 OpenGL 合成的 Compositor)可以讓你更好地管理窗口的顯示效果,比如陰影、透明度等。以下是詳細的步驟指南:

1. 安裝 Compton

首先,你需要安裝 Compton。你可以使用 yum 或者 dnf 來安裝。

sudo yum install epel-release
sudo yum install compton

或者使用 dnf

sudo dnf install compton

2. 配置 Compton

Compton 的配置文件通常位于 /etc/compton.conf,但你可以創建自己的配置文件并指定路徑。

創建配置文件

你可以創建一個新的配置文件,例如 ~/.compton.conf,并在其中添加你的配置選項。以下是一個基本的配置示例:

backend = "glx";
shadow-exclude = [ "WINDOW_CLASS=.*Firefox" ];
glx-no-stencil = true;
glx-damage = false;

啟動 Compton

你可以手動啟動 Compton 并指定配置文件路徑:

compton --config ~/.compton.conf

3. 設置 Compton 自動啟動

為了讓 Compton 在系統啟動時自動運行,你可以將其添加到你的桌面環境的啟動腳本中。

GNOME

如果你使用的是 GNOME,可以使用 gnome-shell-extension-prefs 來管理擴展。你可以創建一個自定義的 GNOME Shell 擴展來啟動 Compton。

  1. 創建一個新的擴展目錄:

    mkdir -p ~/.local/share/gnome-shell/extensions/compton@yourusername
    cd ~/.local/share/gnome-shell/extensions/compton@yourusername
    
  2. 創建 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;
        }
    }
    
  3. 創建 metadata.json 文件:

    {
        "uuid": "compton@yourusername",
        "name": "Compton",
        "description": "Compositor using OpenGL",
        "shell-version": ["3.36", "3.38", "40", "42"]
    }
    
  4. 啟用擴展:

    打開 GNOME Tweak Tool,導航到 Extensions 部分,找到并啟用你的 Compton 擴展。

KDE Plasma

如果你使用的是 KDE Plasma,可以使用 kstart 來啟動 Compton。

  1. 創建一個 kstart 腳本:

    mkdir -p ~/.config/autostart
    nano ~/.config/autostart/compton.desktop
    
  2. 添加以下內容:

    [Desktop Entry]
    Type=Application
    Exec=compton --config ~/.compton.conf
    Hidden=false
    NoDisplay=false
    X-GNOME-Autostart-enabled=true
    Name=Compton
    
  3. 保存并退出。

4. 調試

如果你遇到問題,可以查看 Compton 的日志輸出:

compton --config ~/.compton.conf --log-level debug

這將幫助你診斷配置中的問題。

通過以上步驟,你應該能夠在 CentOS 上成功配置并運行 Compton。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女