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:
vlc foo
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/usr/share/kde4/services/
- If you don't already have one, create a subdirectory named
ServiceMenus
. - Within the new directory, create a file named
vlc.desktop
and add the following content to it:
[Desktop Entry]
Actions=VLCQueue
Icon=vlc
ServiceTypes=KonqPopupMenu/Plugin,inode/directory,inode/directory-locked
Type=Service
X-KDE-Priority=TopLevel
This code basically says that you are creating a[Desktop Entry]
which performsActions
namedVLCQueue
(you can declare many more if you like separated by a semi-colon). TheServiceTypes
notes 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]
Exec=vlc %f
Icon=vlc
Name=Queue in VLC
TheExec
line 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 :)
Update:
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.
- Log in to post comments