I was looking for a way to add a custom context (right-click) menu to KDE's Dolphin (in Kubuntu 14.10, Utopic) that (much like in Windows) would allow me to enqueue an entire folder/directory in Videolan. Many of the examples that I looked at were rather sketchy or incomplete. Here's a simple working example that might be of help to someone else out there. You can modify it appropriately to get it working for other applications as well.
- First of all, find out the command to enqueue an entire directory in VLC from the command line. VLC (god bless its soul) simply works with:
where foo is a directory full of videos. VLC also looks through sub-directories recursively by default. Easy Peasy Nipponese.
- Next, navigate to
/home/druss/.kde/share/kde4/services/where druss is your username. This is where we will add the code for our custom menu assuming that we only want it to be accessible to you and not everybody on the system. If you want this menu to be accessible to all users on the system, you will need to look for something like
- If you don't already have one, create a subdirectory named
- Within the new directory, create a file named
vlc.desktopand add the following content to it:
This code basically says that you are creating a
[Desktop Entry]which performs
VLCQueue(you can declare many more if you like separated by a semi-colon). The
ServiceTypesnotes that we only want this menu to appear when right-clicking on a folder.
- Now below the above section, add the "Action" that we have specified:
[Desktop Action VLCQueue]
Name=Queue in VLC
Execline simply specifies the command to run (with the folder name being provided by the
%f). We also specify a display name and an icon to use (and in this case, just vlc worked great)!
- Save the file.
- Now, close all the instances of Dolphin that you have open on your desktop.
- Reopen Dolphin. Right-click on a folder and you should see a Queue in VLC option right at the bottom. Clicking it should queue and play the contents of the folder in VLC.
And that's all there is to it. For more complicated operations with Service Menus, I would normally recommend looking through the docs. But the docs are mostly either confusing, incoherent, or simply out of fucking date. In this case, I'd say that you'd have better luck looking through and examining the custom service menus that are available for download through Dolphin itself. For this, open Dolphin options (Control, Configure Dolphin), click on Services, and choose to Download New Services. Find an add-on that promises to do something similar to what you want and install it. You can then take its .desktop file apart within the ServiceMenus directory.
Hope this helps someone out there :)
For KDE5, the directory to save the
vlc.desktop has changed to
/home/druss/.local/share/kservices5/ServiceMenus/. This is what worked for me in Kubuntu 17.10.