Skip to main content

桌面启动器操作

¥Desktop Launcher Actions

概述

¥Overview

在许多 Linux 环境中,你可以通过修改 .desktop 文件向系统启动器添加自定义条目。有关 Canonical 的 Unity 文档,请参阅 向启动器添加快捷方式。有关更通用实现的详细信息,请参阅 freedesktop.org 规范

¥On many Linux environments, you can add custom entries to the system launcher by modifying the .desktop file. For Canonical's Unity documentation, see Adding Shortcuts to a Launcher. For details on a more generic implementation, see the freedesktop.org Specification.

audacious

注意:上面的屏幕截图是 Audacious 音频播放器中启动器快捷方式的示例

¥NOTE: The screenshot above is an example of launcher shortcuts in Audacious audio player

要创建快捷方式,你需要为要添加到快捷菜单的条目提供 NameExec 属性。当用户单击快捷菜单项后,Unity 将执行 Exec 字段中定义的命令。.desktop 文件的示例可能如下所示:

¥To create a shortcut, you need to provide Name and Exec properties for the entry you want to add to the shortcut menu. Unity will execute the command defined in the Exec field after the user clicked the shortcut menu item. An example of the .desktop file may look as follows:

Actions=PlayPause;Next;Previous

[Desktop Action PlayPause]
Name=Play-Pause
Exec=audacious -t
OnlyShowIn=Unity;

[Desktop Action Next]
Name=Next
Exec=audacious -f
OnlyShowIn=Unity;

[Desktop Action Previous]
Name=Previous
Exec=audacious -r
OnlyShowIn=Unity;

Unity 指示应用执行操作的首选方法是使用参数。你可以在应用的全局变量 process.argv 中找到它们。

¥The preferred way for Unity to instruct your application on what to do is using parameters. You can find them in your application in the global variable process.argv.