Customizing File Manager Menus in KDE4

April 8, 2010 by
Filed under: HowTo, KDE, linux, Ubuntu 

I've shown previously how to customize the Nautilus File Manager in GNOME/Ubuntu with Nautilus Actions. Today I'll show how to add custom items to the file manager context menu in KDE4/Kubuntu.

The KDE customizations work through desktop configuration files. These are the same type of files used to configure shortcuts on your desktop. When these files are placed inside the proper directories, they are used to create custom context menu items. These files can be stored in two places: 

  1. /home/yourid/.kde/share/kde4/services/ServiceMenus/ - These are customizations for your personal user ID.
  2. /usr/share/kde4/services/ServiceMenus/ - These are system wide customizations that will work for all users.

You can use the existing files in /usr/share/kde4/services/ServiceMenus/ as examples to create your own custom actions. For this tutorial, I'm going to use the same watermarking script that I used in the Nautilus Actions Watermark tutorial. Follow that tutorial to create the script on your system and make it executable.

Now that you have the script, you can make your custom KDE action. I'm going to place the .desktop file in the personal customizations directory. Open a terminal and navigate to the directory:

cd ~/.kde/share/kde4/services

Unless you've already set up a custom action before, you're probably missing the correct directory for storing your .desktop file. Create it with:
mkdir ServiceMenus

Now, open a text editor and paste the following text.

Affiliate Link
[Desktop Entry]
Encoding=UTF-8
ServiceTypes=KonqPopupMenu/Plugin,image/*
TryExec=/home/yourid/bin/auto_wm
Type=Service
Actions=watermark;
TryExec=/home/yourid/bin/auto_wm

[Desktop Action watermark]
Name=Watermark
Icon=ksplash
Exec=/home/yourid/bin/auto_wm %f


Make the appropriate changes to the paths for your script location and then save the file as watermark.desktop in /home/yourid/.kde/share/kde4/services/ServiceMenus/.

That's all there is to it. Now when you right click on images in the file manager, the Watermark function will come up under the Actions sub-menu.

KDE Watermark Action

KDE Watermark Action

The really cool thing here is that this is core KDE functionality, so this new menu item will show up whether you use Dolphin or Konqueror as your file manager.

Comments

One Response to “Customizing File Manager Menus in KDE4”

  1. Story added...

    This story has been submitted to fsdaily.com! If you think this story should be read by the free software community, come vote it up and discuss it here:

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>