You are here

Adding a custom (service) menu to KDE's Dolphin (to queue a folder in VLC)

Submitted by Druss on Sat, 2015-08-29 22:07

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.

  1. 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.
  2. 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/
  3. If you don't already have one, create a subdirectory named ServiceMenus.
  4. 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 performs Actions named VLCQueue (you can declare many more if you like separated by a semi-colon). The ServiceTypes notes that we only want this menu to appear when right-clicking on a folder.
  5. Now below the above section, add the "Action" that we have specified:
    [Desktop Action VLCQueue]
    Exec=vlc %f
    Icon=vlc
    Name=Queue in VLC

    The Exec 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)!
  6. Save the file.
  7. Now, close all the instances of Dolphin that you have open on your desktop.
  8. 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 :)