简体   繁体   中英

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.

Initially, I've right-clicked on a Launcher Chromium menu entry -> Add to Desktop... and the shortcut got created. However, it's just a symlink to /usr/share/applications/chromium.desktop and I can't modify it.

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. However even before editing it, it 's unable to launch Chromium. It displays the following message box when double-clicked:

Unknown error code 100 You are not authorized to execute this file. Please send a full bug report at 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?

You need to make the copied chromium.desktop file executable. With Dolphin file manager: right-click on your .desktop file → PropertiesPermissions tab → check Is executable checkbox.

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

 chmod 755 chromium.desktop

Now it should be able to launch 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:

/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.

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]= , eg 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

To add your new launcher to the application menus (for the current user) - move .desktop file to the

~/.local/share/applications/

Now your launcher will be available in Application Launcher and 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 .

Run this command at root directory:

ln -s $PWD ~/Desktop/

Thank me later!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM