15

I've Googled around, but can't seem to find any consistent tutorials or documentation that describe how to do this (in my case, on Kubuntu 15.10). I want to add custom scripts to the context menu in Dolphin (a la nautilus-scripts for Nautilus). For some reason, when I follow any instructions I find, I'm only able to make the context menu appear when right-clicking the relevant .desktop file. How can I solve this?

20

KDE Service Menus

In KDE-speak a "servicemenu" is a special entry that appears in a context menu (or other context-based interface) for a file (or for directory), depending on the type of files that are selected.

Service Menus with Dolphin:

Service Menus Missing: https://forum.kde.org/viewtopic.php?f=223&t=128621

Paths

KDE Frameworks 5 is looking services from:

kf5-config --path services

Executing:

$ kf5-config --path services
/home/user26687/.local/share/kservices5/:/usr/share/kservices5/

That is:

User servicemenus are:

$HOME/.local/share/kservices5/ServiceMenus/

System servicemenus are at

/usr/share/kservices5/ServiceMenus/

Desktop files

Servicemenus are defined using .desktop files. Desktop Entry Specification: https://standards.freedesktop.org/desktop-entry-spec/latest/

Image: Desktop Entry Specification has the meaning of the keys/codes Image: Sample of the Desktop Entry Specification keys/codes

An example - simple servicemenu with file path:

Making: $HOME/.local/share/kservices5/ServiceMenus/myFirstServiceMenu.desktop

If the directory doesn't exist the user can make it !

[Desktop Entry]
Type=Service
Icon=smiley-shape
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
MimeType=all/allfiles;
Actions=helloWorld;
Encoding=UTF-8

[Desktop Action helloWorld]
Name=Hello with path information
Icon=smiley-shape
Exec=kdialog --msgbox "Path is %f"

Image: a servicemenu at the right place. Image: a servicemenu at the right place.

Closing all Dolphin windows and starting a new one. When right clicking a file:

Image: sample of the servicemenu action

2
  • Please add the relevant part of the answer here and provide the links only for reference.
    – Anwar
    Jun 16 '17 at 13:57
  • If you are editing the service action while you configure it, you may need to (1) delete the service.desktop file (keeping it open in your editor), (2) open and close dolphin so that it thinks that the service disappeared, (3) recreate the new service file by saving it, (4) reopen dolphin. Nov 16 '20 at 21:13
4

The following worked for me on Ubuntu 16.04

place the scripts in the directory ~/.local/share/kservices5/ServiceMenus/

run kbuildsycoca5

scripts will be visible in new dolphin instances.

1
  • I tried this even prior to placing my scripts directory in there an error: The menu spec file contains a Layout or DefaultLayout tag without the mandatory Merge tag inside. I was hoping to dump a folder with about 100 bash shell scripts I wrote and get to them from the menu. Not keen to make make a .desktop file for 100 .sh files is all. I wonder if I can put a folder into the menus?
    – Tomachi
    Mar 31 at 12:00
1

On Ubuntu 16.04 with KDE (Kubuntu) one appropriate directory for *.desktop files is /usr/share/kservices5/ServiceMenus/

(compare the output of dpkg -L ark to find similar file locations concerning the ark submenus)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.