Linux系统中Compton安装步骤
导读:Linux系统中Compton安装步骤 一 安装方式概览 使用发行版包管理器安装(推荐):适用于Ubuntu/Debian、Fedora、CentOS/RHEL、Arch Linux等,命令简单、便于维护。 从源码编译安装:适用于需要最新...
Linux系统中Compton安装步骤
一 安装方式概览
- 使用发行版包管理器安装(推荐):适用于Ubuntu/Debian、Fedora、CentOS/RHEL、Arch Linux等,命令简单、便于维护。
- 从源码编译安装:适用于需要最新特性或特定分支的场景,可控性强但步骤更多。
二 发行版包管理器安装
- Ubuntu/Debian
- 更新索引并安装:
sudo apt update & & sudo apt install compton
- 更新索引并安装:
- Fedora/CentOS/RHEL
- 安装:
sudo dnf install compton(如为RHEL/CentOS且仓库缺失,先启用EPEL)
- 安装:
- Arch Linux
- 安装:
sudo pacman -S compton
- 安装:
- 以上完成后即可在对应会话中启动使用(见第四节)。
三 从源码编译安装
- 安装依赖(以Debian/Ubuntu为例):
sudo apt install git cmake libx11-dev libxrandr-dev libxkbcommon-dev libxcb-xinerama0-dev libxcb-randr0-dev libxcb-shm0-dev libxcb-xinput-dev pkg-config - 获取源码并构建:
git clone https://github.com/chjj/compton.gitcd compton & & mkdir build & & cd buildcmake .. & & make -j$(nproc)sudo make install
- 其他发行版请安装等价的X11/渲染开发库后再编译(名称可能不同)。
四 启动与开机自启
- 手动启动
- 直接运行:
compton - 指定配置:
compton --config ~/.config/compton.conf
- 直接运行:
- 登录自启的常见做法
- 会话级(推荐):将
compton --config ~/.config/compton.conf加入桌面会话的自启动应用(如“启动应用程序”)。 - Systemd 用户服务(无显示管理器或需用户级服务时):
- 新建:
systemctl --user edit --force --full compton.service - 内容示例:
[Unit] Description=Compton Compositor After=graphical-session.target [Service] ExecStart=/usr/bin/compton --config %h/.config/compton.conf Restart=always Environment=DISPLAY=:0 [Install] WantedBy=graphical-session.target - 启用:
systemctl --user daemon-reload & & systemctl --user enable --now compton.service
- 新建:
- 会话级(推荐):将
- 验证运行
- 查看进程:
ps aux | grep compton - 查看版本:
compton --version
- 查看进程:
- 注意
- 若桌面环境自带合成器(如GNOME/KDE默认合成器),可能需要先关闭内置合成器以避免冲突。
- 某些桌面环境并不使用或支持systemd 用户服务,此时应优先采用“会话级自启动”。
五 配置文件与基础调优
- 配置文件位置
- 用户级:
~/.config/compton.conf - 系统级:
/etc/xdg/compton.conf或/etc/compton.conf
- 用户级:
- 常用选项
backend:渲染后端,常用glx或xrendervsync:垂直同步,取值true/falseshadow:窗口阴影,取值true/falseopacity:全局透明度(0.0–1.0)
- 最小可用示例
backend = "glx" vsync = true shadow = true opacity = 0.9 - 应用修改
- 重启 Compton:
killall compton & & compton --config ~/.config/compton.conf & - 或:
systemctl --user restart compton.service(若使用用户级服务)。
- 重启 Compton:
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: Linux系统中Compton安装步骤
本文地址: https://pptw.com/jishu/765681.html
