linux

Linux系统中Compton的设置步骤

小樊
42
2025-10-24 13:15:16
栏目: 智能运维

一、安装Compton
Compton是一款轻量级窗口合成器,支持X11/Wayland环境,能实现窗口透明、阴影、模糊等特效。安装前建议更新系统软件包列表,再根据发行版选择对应命令:

二、配置Compton
Compton的配置文件通常位于用户主目录的.config文件夹下(~/.config/compton.conf)。若文件不存在,可通过以下命令创建:

mkdir -p ~/.config
touch ~/.config/compton.conf

使用文本编辑器(如nanovim)打开配置文件,根据需求调整参数:

1. 基础视觉效果设置

2. 性能优化设置

三、应用配置更改
修改配置文件后,需重启Compton使设置生效。常用方法有两种:

  1. 直接重启Compton进程
    killall compton  # 终止现有Compton进程
    compton --config ~/.config/compton.conf &  # 重新启动(使用自定义配置文件)
    
  2. 使用systemd服务(推荐,支持开机自启)
    若系统使用systemd,可创建Compton服务文件:
    sudo nano /etc/systemd/system/compton.service
    
    添加以下内容(替换为你的配置文件路径):
    [Unit]
    Description=Compton Window Compositor
    After=display-manager.service  # 确保在显示管理器启动后运行
    
    [Service]
    ExecStart=/usr/bin/compton --config ~/.config/compton.conf
    Restart=always  # 崩溃后自动重启
    
    [Install]
    WantedBy=multi-user.target
    
    保存后,执行以下命令启用并启动服务:
    sudo systemctl daemon-reload
    sudo systemctl enable compton  # 设置开机自启
    sudo systemctl start compton   # 立即启动服务
    

四、常见问题排查

0
看了该问题的人还看了