温馨提示×

如何在Linux中设置Compton

小樊
43
2025-03-02 01:28:25
栏目: 智能运维
Linux服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

在Linux中设置Compton,可以按照以下步骤进行:

安装Compton

  1. 使用包管理器安装
  • 对于基于Debian的系统(如Ubuntu):
    sudo apt update
    sudo apt install compton
    
  • 对于基于Red Hat的系统(如Fedora):
    sudo dnf install compton
    
  1. 从源码编译安装(可选): 如果你需要最新版本或特定功能,可以从GitHub克隆源码并编译安装:
git clone https://github.com/astra1us/compton.git
cd compton
mkdir build && cd build
cmake ..
make
sudo make install

配置Compton

  1. 创建配置文件: 默认情况下,Compton会使用~/.config/compton.conf作为配置文件。如果该文件不存在,你可以手动创建一个。

  2. 编辑配置文件: 使用你喜欢的文本编辑器打开或创建compton.conf,例如:

nano ~/.config/compton.conf

以下是一些常用的配置选项:

  • backend: 选择渲染后端,如glxebpf等。
    backend = "glx";
    
  • shadow-exclude: 排除某些窗口不显示阴影。
    shadow-exclude = [
      "class_g = 'Firefox'",
      "class_g = 'Thunderbird'"
    ];
    
  • shadow-opacity: 设置阴影的不透明度。
    shadow-opacity = 0.5;
    
  • blur-radius: 设置模糊半径。
    blur-radius = 4;
    
  • glx-no-stencil: 禁用GLX模板缓冲区(某些情况下可能需要)。
    glx-no-stencil = true;
    
  1. 保存并退出编辑器

启动Compton

  1. 手动启动: 你可以直接在终端中运行Compton来测试配置:
compton
  1. 设置为后台服务: 为了在系统启动时自动运行Compton,你可以创建一个systemd服务文件。
  • 创建服务文件:
    sudo nano /etc/systemd/system/compton.service
    
  • 添加以下内容:
    [Unit]
    Description=Compton Compositor
    After=display-manager.service
    
    [Service]
    ExecStart=/usr/local/bin/compton --config ~/.config/compton.conf
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    
  • 启用并启动服务:
    sudo systemctl enable compton
    sudo systemctl start compton
    

验证设置

打开一个应用程序窗口,检查阴影效果是否符合你的配置。如果有问题,可以调整compton.conf中的参数并重新启动Compton。

通过以上步骤,你应该能够在Linux系统中成功设置和使用Compton。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:如何在Linux中优化Compton设置

0