如何创建传递自定义参数的桌面快捷方式?

How to create desktop shortcut passing custom arguments?

我有 KDE 5.20.5,想创建一个桌面快捷方式来启动 Chromium,并向其传递自定义命令行参数。

最初,我右键单击 Launcher Chromium 菜单项 -> Add to Desktop... 并创建了快捷方式。但是,它只是 /usr/share/applications/chromium.desktop 的符号链接,我无法修改它。

然后,我尝试手动将 /usr/share/applications/chromium.desktop 复制到我的桌面上,这样我就可以修改副本而不触及原件。然而,即使在编辑它之前,它也无法启动 Chromium。双击时显示如下消息框:

Unknown error code 100 You are not authorized to execute this file. Please send a full bug report at https://bugs.kde.org.

我用谷歌搜索了这样一个基本问题的答案:基于 KDE Plasma 中的 Launcher 菜单条目创建可修改桌面快捷方式的正确\推荐方法是什么?

您需要使复制的 chromium.desktop 文件可执行。使用 Dolphin 文件管理器:右键单击您的 .desktop 文件 → PropertiesPermissions 选项卡 → 检查 Is executable 复选框。

Alternatively, from the folder with your .desktop file, you can run:

chmod 755 chromium.desktop

现在应该可以启动 Chromium 了。

要向启动器添加自定义参数 (-s) - 回到 .desktop 文件的 Properties,转到 Application 选项卡并将您的参数 (-s) 添加到Command 可执行文件路径后的字段,例如:

/usr/bin/chromium --profile-directory="Default"

当我们在 Application 选项卡时,您可能希望将 Name 字段更改为类似“Chromium w/args”的内容,以帮助稍后区分启动器。

As an option, you can edit the .desktop file by opening it with a text editor of your preference. To edit the launch command, navigate to the [Desktop Entry] group header, under which locate the line starting with Exec= and add custom arguments to it.

To edit the name of the launcher, under the same header locate lines starting with Name= (Name[xx_XX]=, e.g. Name[en_US]= for localized names) and alter them as you wish.

More information on Desktop Entries can be found in its specification or on ArchWiki

要将新启动器添加到应用程序菜单(对于当前用户)- 将 .desktop 文件移动到

~/.local/share/applications/

现在您的启动器将在 Application Launcher 和 Krunner 中可用。

如果您希望新启动器与原始启动器共存(而不是覆盖它),您应该将 .desktop 文件重命名为 chromium_args.desktop.

运行 这个命令在根目录:

ln -s $PWD ~/Desktop/