在~/.config/autostart/目录下,添加xxx.desktop文件,内容如下:

[Desktop Entry]
Type=Application
Name=start apps
NoDisplay=yes # 设置该启动项在系统配置中显示
Exec=path/to/xxx.sh # 可以用相对路径(当前路径是$HOME)
#X-GNOME-Autostart-enabled=true # 使能开机启动(默认)

另外:

  1. xxx.desktop无需执行权限
  2. 该方法支持开机启动GUI。
  3. 直接在xxx.sh中source ~.bashrc不会生效,原因如.bashrc中前面几句所言:
    # If not running interactively, don't do anything
    case $- in
        *i*) ;;
          *) return;;
    esac
  4. 在xxx.desktop中虽然可以使用相对路径,但是不能使用~或则$HOME等。
  5. 在xxx.sh中可以使用~,$HOME等

相关文章:

  • 2021-09-12
  • 2022-12-23
  • 2022-12-23
  • 2021-07-05
  • 2022-12-23
  • 2022-12-23
  • 2022-02-16
  • 2022-12-23
猜你喜欢
  • 2021-10-01
  • 2021-07-17
  • 2022-12-23
  • 2021-12-13
  • 2021-06-28
  • 2022-03-02
  • 2022-12-23
相关资源
相似解决方案