了解 .desktop 文件中的 AutostartCondition 键

了解 .desktop 文件中的 AutostartCondition 键

默认情况下,带有 GNOME 3 Shell 的 CentOS 7.x在key 下提供以下*.desktop文件:/etc/xdg/autostart/AutostartCondition

# gnome-welcome-tour.desktop
[Desktop Entry]
Type=Application
Name=Welcome
Exec=/usr/libexec/gnome-welcome-tour
AutostartCondition=if-exists run-welcome-tour
OnlyShowIn=GNOME;
NoDisplay=true

# gnome-initial-setup-first-login.desktop
[Desktop Entry]
Name=Initial Setup
#...
Icon=preferences-system
Exec=/usr/libexec/gnome-initial-setup --existing-user
Terminal=false
Type=Application
StartupNotify=true
Categories=GNOME;GTK;System;
OnlyShowIn=GNOME;
NoDisplay=true
AutostartCondition=unless-exists gnome-initial-setup-done
#...

我的问题:

  1. 我是否正确地认为AutostartConditionkey 决定了在启动时读取文件后 key 的值是否Exec由 GNOME 3(或另一个 XDG 兼容的桌面或会话管理器)执行/etc/xdg/autostart/*.desktop
  2. 如何查询 的当前值AutostartCondition

关于问题#2:我尝试了以下操作,但没有成功(我已经完成了 gnome-welcome-tour 和 gnome-initial-setup,并且在登录时没有提示):

[user@user-centos-7 ~]$ gconftool-2 --recursive-list / | grep gnome-initial-setup-done
[user@user-centos-7 ~]$ gsettings list-schemas | while read -r SCHEMA; do gsettings list-recursively $SCHEMA; done | grep gnome-initial-setup-done
[user@user-centos-7 ~]$ 
[user@user-centos-7 ~]$ gconftool-2 --recursive-list / | grep run-welcome-tour
[user@user-centos-7 ~]$ gsettings list-schemas | while read -r SCHEMA; do gsettings list-recursively $SCHEMA; done | grep run-welcome-tour
[user@user-centos-7 ~]$ 

答案1

会话管理器读取.desktop所有启动应用程序的文件。如果AutostartCondition在这些文件中的任何一个中找到一个键,它会检查其值:如果不满足条件,则该特定应用程序将从启动应用程序列表中删除。自动启动条件在一篇非常旧的帖子中描述自由桌面邮件列表:

The Autostart-Condition Key

The Autostart-Condition key gives a condition which should be tested before
autostarting the application; if the condition is not met, then the application
MUST NOT be autostarted. The condition can be in one of the following forms:

    if-exists FILE

        The application should only be autostarted if FILE exists
        (relative to $XDG_CONFIG_HOME).

    unless-exists FILE

        The application should only be autostarted if FILE *doesn't* exist
        (relative to $XDG_CONFIG_HOME).

    DESKTOP-ENVIRONMENT-NAME [DESKTOP-SPECIFIC-TEST]

        The application should only be autostarted under the named desktop environment
        (as with OnlyShowIn). If DESKTOP-SPECIFIC-TEST is also given, the desktop
        environment will evaluate it in some manner specific to that desktop to
        determine whether or not the application should be autostarted.


which would end up being used like:

Name=kgpg
# start only under KDE, and only if the given kconfig key is set
Autostart-Condition=KDE kgpgrc:User Interface:AutoStart:false

Name=vino
# start only under GNOME, and only if the given gconf key is set
Autostart-Condition=GNOME /desktop/gnome/remote_access/enabled

Name=beagled
# start under any desktop environment, unless
# ~/.config/beagle/disable-autostart exists
Autostart-Condition=unless-exists beagle/disable-autostart

因此,在您的特定情况下,自动启动条件./config/run-welcome-tour分别是存在和./config/gnome-initial-setup-done不存在。

相关内容