温馨提示×

linux compton如何开机启动

小樊
43
2026-09-06 21:06:09
栏目: 智能运维

在 Linux 中让 compton(现在很多发行版叫 picom)开机启动,取决于你使用的桌面环境 / 显示管理器 / 启动方式。下面按常见情况说明。


一、使用桌面环境(最常见)

1. GNOME / KDE / XFCE / LXDE / Mint 等

一般都有“启动应用程序”的功能。

图形界面方式

  • 打开 启动应用程序(Startup Applications)
  • 添加一项:
    • 名称:Compton
    • 命令:comptoncompton --config ~/.config/compton.conf
    • 注释:随意

如果是 picom:命令写 picom


2. 手动添加 autostart 文件(通用 X11)

适用于大多数桌面环境(XFCE、LXDE、KDE、GNOME)

mkdir -p ~/.config/autostart

创建文件:

~/.config/autostart/compton.desktop

内容:

[Desktop Entry]
Type=Application
Name=Compton
Exec=compton --config ~/.config/compton.conf
NoDisplay=false
X-GNOME-Autostart-enabled=true

如果使用 picom:

Exec=picom --config ~/.config/picom.conf

二、使用窗口管理器(i3 / bspwm / awesome 等)

i3

~/.config/i3/config 里加:

exec --no-startup-id compton

或:

exec --no-startup-id picom

bspwm

~/.config/bspwm/bspwmrc

compton &

或:

picom &

三、systemd 用户服务(进阶,不推荐新手)

mkdir -p ~/.config/systemd/user

创建:

~/.config/systemd/user/compton.service

内容:

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

[Service]
ExecStart=/usr/bin/compton --config %h/.config/compton.conf
Restart=on-failure

[Install]
WantedBy=default.target

启用:

systemctl --user enable compton
systemctl --user start compton

四、常见问题

1. 启动太早导致黑屏

可加延迟:

Exec=sleep 2 && compton

2. 确认是否运行

ps aux | grep compton

3. compton / picom 分不清

  • 老版:compton
  • 新版 fork:picom

如果你告诉我:

  • 发行版(Ubuntu / Arch / Debian?)
  • 桌面环境或窗口管理器

我可以给你最准确的一条命令

0