[英]How to create desktop shortcut passing custom arguments?
I have KDE 5.20.5 and would like to create a desktop shortcut for launching Chromium passing custom command line arguments to it.我有 KDE 5.20.5,想创建一个桌面快捷方式来启动 Chromium,将自定义命令行 arguments 传递给它。
Initially, I've right-clicked on a Launcher Chromium menu entry -> Add to Desktop...
and the shortcut got created.最初,我右键单击 Launcher Chromium 菜单项 ->
Add to Desktop...
,然后创建了快捷方式。 However, it's just a symlink to /usr/share/applications/chromium.desktop
and I can't modify it.但是,它只是
/usr/share/applications/chromium.desktop
的符号链接,我无法修改它。
Then, I've tried to copy that /usr/share/applications/chromium.desktop
onto my desktop manually so I could modify the copy and not touch the original.然后,我尝试手动将
/usr/share/applications/chromium.desktop
复制到我的桌面上,这样我就可以修改副本而不触及原始文件。 However even before editing it, it 's unable to launch Chromium.然而,即使在编辑之前,它也无法启动 Chromium。 It displays the following message box when double-clicked:
双击时显示以下消息框:
Unknown error code 100 You are not authorized to execute this file.
未知错误代码 100 您无权执行此文件。 Please send a full bug report at https://bugs.kde.org .
请在https://bugs.kde.org发送完整的错误报告。
I've sweated googling an answer to such the basic question: what is correct \ recommended way of creating a modifiable desktop shortcut based on a Launcher menu entry in KDE Plasma?我已经在谷歌上搜索了这样一个基本问题的答案:什么是正确的\推荐的基于 KDE Plasma 中的启动器菜单条目创建可修改桌面快捷方式的方法?
You need to make the copied chromium.desktop file executable.您需要使复制的chromium.desktop文件可执行。 With Dolphin file manager: right-click on your .desktop file →
Properties
→ Permissions
tab → check Is executable
checkbox.使用Dolphin文件管理器:右键单击您的.desktop文件 →
Properties
→ Permissions
选项卡 → 选中Is executable
复选框。
Alternatively, from the folder with your .desktop file, you can run:
或者,从包含.desktop文件的文件夹中,您可以运行:
chmod 755 chromium.desktop
Now it should be able to launch Chromium.现在它应该能够启动 Chromium。
To add a custom argument(-s) to the launcher - back in the Properties
of your.desktop file go to the Application
tab and add your argument(-s) to the Command
field after the path to the executable, for example:要将自定义参数 (-s) 添加到启动器 - 回到 your.desktop 文件 go 的
Properties
中的Application
选项卡,并将您的参数 (-s) 添加到可执行文件路径后的Command
字段中,例如:
/usr/bin/chromium --profile-directory="Default"
While we are at the Application
tab, you may want to change the Name
field to something like "Chromium w/args" to help distinguish launchers later on.当我们在“
Application
”选项卡中时,您可能希望将“ Name
”字段更改为“Chromium w/args”之类的内容,以帮助稍后区分启动器。
As an option, you can edit the .desktop file by opening it with a text editor of your preference.
作为一个选项,您可以通过使用您喜欢的文本编辑器打开.desktop文件来对其进行编辑。 To edit the launch command, navigate to the
[Desktop Entry]
group header, under which locate the line starting withExec=
and add custom arguments to it.要编辑启动命令,请导航到
[Desktop Entry]
组 header,在该组下找到以Exec=
开头的行并添加自定义 arguments 到它。To edit the name of the launcher, under the same header locate lines starting with
Name=
(Name[xx_XX]=
, egName[en_US]=
for localized names) and alter them as you wish.要编辑启动器的名称,请在同一 header 下找到以
Name=
开头的行(Name[xx_XX]=
,例如Name[en_US]=
用于本地化名称)并根据需要更改它们。More information on Desktop Entries can be found in its specification or on ArchWiki
有关桌面条目的更多信息可以在其规范或ArchWiki中找到
To add your new launcher to the application menus (for the current user) - move .desktop file to the要将新启动器添加到应用程序菜单(针对当前用户) - 将.desktop文件移动到
~/.local/share/applications/
Now your launcher will be available in Application Launcher and Krunner.现在您的启动器将在 Application Launcher 和 Krunner 中可用。
If you want the new launcher to co-exist with the original (instead of overriding it), you should rename the .desktop file to something like chromium_args.desktop .如果您希望新启动器与原始启动器共存(而不是覆盖它),您应该将.desktop文件重命名为chromium_args.desktop之类的名称。
Run this command at root directory:在根目录运行此命令:
ln -s $PWD ~/Desktop/
Thank me later!晚点再谢我!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.