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:
- /home/yourid/.kde/share/kde4/services/ServiceMenus/ - These are customizations for your personal user ID.
- /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:
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:
Now, open a text editor and paste the following text.
[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.
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.