Linux图形桌面自启动程序设定

方法一:使用图形界面

  1. 打开设置窗口
    • GNOME安装gnome-startup-applications(20.04后);在控制中心(Control Center)中寻找Startup Applications程序;或是在控制中心寻找Startup Applications Preferences选项[1]
    • MATE在控制中心(Control Center)中寻找Startup Applications选项[2]
  2. 增加启动项
    • Startup Applications Preferences窗口中新增项目,填写名称和命令。
  3. 重启检查效果

方法二:使用非图形界面

GUI操作的本质,是在~/.config/autostart/下增加一系列扩展名为.desktop的配置文件。每个启动项一个配置文件。

以qBittorrent软件的启动配置为例,文件内容为——

qbittorrent.desktop
1
2
3
4
5
6
7
8
9
[Desktop Entry]
Type=Application
Exec=/usr/bin/qbittorrent --no-splash
Hidden=false
NoDisplay=false
Name[zh_CN]=qBittorrent
Name=qBittorrent
Comment[zh_CN]=
Comment=

注意:GUI会默认在配置中加入一行

1
X-GNOME-Autostart-enabled=true

这会导致开启远程桌面时再启动一次(待验证,有人报道这个选项已经无效),对于qBittorrent这显然是有害的。

参考

  1. (GNOME) How do I start applications automatically on login? - Ask Ubuntu
  2. (MATE) How to automatically start programs on Mate - AddictiveTips