Is it possible to add new items into context menu in Dolphin (KDE Plasma) if I right click on something?
I would like to make a script called Move to applications, which will show only if I right click on a .desktop file and then it will move it to /usr/share/applications/ folder. Or is there a faster way for moving .desktop files to /usr/share/applications/ folder.
You can create a Service Menu to do what you want.
Paste the following content into move.desktop
The use of
MimeType=application/x-desktop;
ensures that this context menu entry will be seen only when the target file is a .desktop file.This is an image of Dolphin's context menu before creating the service menu:
In the following screenshot taken after creating the service menu you'll see an additional entry, Move file:
Clicking on Move file will prompt you for your password because you want to move a file into /usr/share/applications.
After providing your password, the selected file will be moved to /usr/share/applications:
Note that the owner isn't the same as .desktop files already there. You'll need to fix that however you choose:
In case you need to change ownership/permissions, you could modify the
Exec=
line like this (to change ownership):The additional steps involve using printf and xsel to put the path of the file into the clipboard and then using basename to strip off everything but the filename. Of course, you'll need
kdesu
again! I don't know if there's a shorter way!Under KDE Plasma, the simplest solution may be to add a new "open with" entry. To do so, go to Configure Desktop (
systemsettings5
) > Applications > File Associations.Then choose the relevant file type using the search field; It will give results both for mimetype names and file extension filters. Typing
.kdelnk
or.desktop
will bring up the mime-typeapplication/x-desktop
.In the panel
Application Preference Order
, click the button + Add to configure the new program. By default new entries are chosen as the default program; You will want to move the script to a more suitable position in the order.