我很想知道您可以从 Dock 访问的“启动应用程序”如何工作。
我想知道这一点,因为我想知道在这些地方添加条目的区别:
/etc/rc.local
/etc/profile
/home/$USER/.profile
Run Code Online (Sandbox Code Playgroud)
并通过此 GUI 应用程序执行相同操作。让我感到困惑的是,我没有看到程序在上述文件中创建任何条目。
/etc/rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
Run Code Online (Sandbox Code Playgroud)
本质上,多用户运行级别意味着在您启动时。
/etc/profile
该文件仅为登录 shell 调用,因为这是它的特定用途。
/etc/profile,当作为登录 shell 启动时,由所有与 Bourne 兼容的 shell(包括bash和dash)运行。
/home/$USER/.profile
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash if ~/.bash_profile or ~/.bash_login
# exists.
Run Code Online (Sandbox Code Playgroud)
无论是
~/.bashrc和~/.bash_profile是被调用的bash时可能执行的脚本。~/.bashrc当您使用非登录 shell 的交互式 shell 运行 bash 时,将执行该文件。在~/.bash_profile登录shell中只得到执行。
所以我认为.profile如果两者都不是(无论出于何种原因)都会被执行。
最后,您的 GUI 方法可能是将.desktop启动器放入/home/$USER/.config/autostart
这是在用户登录时运行的(我认为只有 GUI 登录 -startx但不会tty登录)。
我的代词是他/他
任何遵循freedesktop 规范(又名 XDG)的桌面环境都应该在用户登录或插入可移动介质时使用自动启动应用程序。
为了在用户登录时自动启动应用程序,桌面环境会寻找一个.desktop文件来执行在那里指定的应用程序。这些.desktop文件通常位于
$XDG_CONFIG_DIRS/autostart
Run Code Online (Sandbox Code Playgroud)
但我们也可以将它们放在以下位置:
~/.config/autostart/ ## if $XDG_CONFIG_HOME is not set
etc/xdg/autostart/ ## if $XDG_CONFIG_DIRS is not set
Run Code Online (Sandbox Code Playgroud)
在任何情况下,.desktop位于 中的文件都~/.config/autostart被定义为要运行的最重要的文件,从而覆盖.desktop其他位置的文件。
Ubuntu 满足此规范,用户可以使用 GUI 方法将应用程序添加到“自动启动应用程序”。
应用程序可以独立于桌面从各种其他位置自动启动,例如~/.profile外壳、在/etc/rc.local系统启动时运行,或者最近使用systemd。
| 归档时间: |
|
| 查看次数: |
1040 次 |
| 最近记录: |