12.2. 自定义默认的最热门程序

最热门程序是那些在“活动概览”中的 GNOME Shell dash 上可见的程序。可以使用“dconf”来为个别用户设置最热门程序,或为所有用户设置相同的最热门程序。

12.2.1. 为个别用户设置不同的最热门程序

可以通过修改 ~/.config/dconf/user 中找到的用户数据库文件来为个别用户设置默认最热门程序。以下样本文件中通过“dconf”将 geditTerminalNautilus 设置为某个用户的默认最热门程序。如果用户希望的话,该例子代码可以允许他们以后修改清单。

例 12.3. /etc/dconf/profile 文件的内容:

# This line allows the user to change the default favorites later
user-db:user

例 12.4. ~/.config/dconf/user 文件的内容:

# Set gedit, terminal and nautilus as default favorites
[org/gnome/shell]
favorite-apps = ['gedit.desktop', 'gnome-terminal.desktop', 'nautilus.desktop']

注意

您也可以锁定上述设置来阻止用户改变它们。更多信息请参见〈第 9.5.1 节 “锁定特定设置”〉。

12.2.2. 为所有用户设置相同的最热门程序

为了使所有用户拥有相同的最热门程序,必须通过“dconf”密钥文件修改系统的数据库文件。以下样本文件修改了“dconf”配置文件,然后创建了一个键值文件来设置某个机构内一楼所有员工的默认最热门程序。

例 12.5. /etc/dconf/profile 文件的内容:

user-db:user

# This line defines a system database called first_floor
system-db:first_floor

注意

用户”数据库文件中的设置优先于“first_floor”数据库文件中的设置,但“first_floor”数据库文件中引入的锁定优先于出现在“用户”中的锁定。关于锁定的更多信息,请参见〈第 9.5.1 节 “锁定特定设置”〉。

例 12.6. /etc/dconf/db/first_floor.d/00_floor1_settings 文件的内容:

# This sample sets gedit, terminal and nautilus as default favorites
# for all users in the first floor
[org/gnome/shell]
favorite-apps = ['gedit.desktop', 'gnome-terminal.desktop', 'nautilus.desktop']
通过运行 dconf update 命令将您的更改合并到系统数据库中。