当前位置: 首页 > 文档资料 > Electron 中文文档 >

自定义 Linux 桌面启动器行为

优质
小牛编辑
193浏览
2023-12-01

在很多的 Linux 环境中,你可以通过修改文件 .desktop 来在它的启动器中添加自定义条目。 关于Canonical 的 Unity 启动器文档, 参考 Adding Shortcuts to a Launcher. 可以通过 freedesktop.org Specification网站,找到更详细的参考信息。

Audacious 的启动器快捷方式:

audacious

一般情况下,在快捷键menu中为每一个条目添加NameExec属性就可以将其设置为快捷键。 用户点击快捷见时,Unity启动器就会执行Exec 属性。 其形式如下:

Actions=PlayPause;Next;Previous
[Desktop Action PlayPause]
Name=Play-Pause
Exec=audacious -t
[Desktop Action Next]
Name=Next
Exec=audacious -f
[Desktop Action Previous]
Name=Previous
Exec=audacious -r

Unity启动器通常通过参数的形式来操作应用。 你在应用的全局变量process.argv中发现这一规律。

Custom Linux Desktop Launcher Actions

On many Linux environments, you can add custom entries to its 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.

Launcher shortcuts of Audacious:

audacious

Generally speaking, shortcuts are added by providing a Name and Exec property for each entry in the shortcuts menu. Unity will execute the Exec field once clicked by the user. The format is 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's preferred way of telling your application what to do is to use parameters. You can find these in your app in the global variable process.argv.