温馨提示×

ubuntu compton怎么开机启动

小樊
34
2026-10-07 01:45:56
栏目: 智能运维

在 Ubuntu 上让 Compton(或已更名为 Picom) 开机启动,有几种常见方式。下面按「推荐程度」给你说明。


一、使用桌面环境自带的“开机启动”(最推荐)

如果你用的是:

  • Ubuntu GNOME
  • Ubuntu 22.04 / 24.04
  • X11 会话(不是 Wayland)

步骤

  1. 打开 “启动应用程序”(Startup Applications)

    gnome-session-properties
    

    如果提示没有这个命令:

    sudo apt install gnome-startup-applications
    
  2. 点击 添加

    • 名称:Compton
    • 命令:
      compton
      
      或(如果你用 picom):
      picom
      
    • 注释:随便写
  3. 保存,重启即可

✅ 适合:普通用户、图形界面登录


二、使用 systemd(用户级,推荐高级用户)

⚠️ 注意:Compton 必须在 X11 登录后 运行,不能太早启动

1. 创建用户 service

mkdir -p ~/.config/systemd/user
nano ~/.config/systemd/user/compton.service

内容:

[Unit]
Description=Compton compositor
After=graphical-session.target

[Service]
ExecStart=/usr/bin/compton
Restart=on-failure

[Install]
WantedBy=graphical-session.target

如果你装的是 picom:

ExecStart=/usr/bin/picom

2. 启用

systemctl --user daemon-reload
systemctl --user enable compton
systemctl --user start compton

✅ 开机自动启动(登录后)


三、使用 ~/.xprofile(简单但不灵活)

编辑:

nano ~/.xprofile

加入:

compton &

或

picom &

⚠️ 只对 X11 + 使用 .xprofile 的会话 有效


四、如果你用的是 Wayland(重要)

❌ Compton / Picom 不支持 Wayland

解决方式:

  • 登录时选择 Ubuntu on Xorg
  • 或使用 Wayland 原生合成器(如 Mutter,无需 Compton)

五、检查是否安装正确

which compton
which picom

如果都没有:

sudo apt install compton
# 或
sudo apt install picom

总结推荐

场景 推荐方式
普通桌面用户 启动应用程序
多用户 / 自动化 systemd user
老式 X11 .xprofile

如果你告诉我:

  • Ubuntu 版本
  • 用的是 compton 还是 picom
  • 桌面环境(GNOME / XFCE / KDE)

我可以给你精确配置。

0 踩