Add a custom service-menu to Dolphin (KDE SC)

Sunday, 13. June 2010

Here is an example for what is possible with very little effort… (a simple shellscript)

 

 

 

Creating custom service menus for dolphin is really really easy!

First of all you’ll have to find out where your .desktop files (services) are located.

kde4-config --path services

In most cases it will be /home/username/.kde/share/kde4/services

In this folder you’ll have to create a new file called:   mynewservice.desktop

To open a specific folder as root for example you would insert the following code: (the one thing that’s important is the “exec” line)

[Desktop Entry]
Type=ServiceIcon=folder-red
Actions=OpenAsRoot
X-KDE-Priority=TopLevel
ServiceTypes=KonqPopupMenu/Plugin,inode/directory,inode/directory-locked
 
[Desktop Action OpenAsRoot]
Exec=kdesu dolphin %U
Icon=folder-red
Name=Open as Root

To add a service menu that will show up on images only you’ll have to define the “MimeType”. As you can see in the following example it is also possible to start a specific script and pass %D (directory) and %U (selected items/files) to the script  (whatever you need).

[Desktop Entry]
Actions=Resize
Icon=transform-crop-and-resize
MimeType=image/*
ServiceTypes=KonqPopupMenu/Plugin
Type=Service
X-KDE-Priority=TopLevel
 
[Desktop Action Resize]
Exec=~/.kde/share/kde4/services/resize.sh %D %U
Icon=transform-scale
Name=Resize Image(s)

or maybe execute the code directly (not always working as reliable as an external script):

Exec=count=0; for f in %F; do convert "$f" "${f%.*}.pdf"; count=`expr $count + 1`; done; kdialog --title "image2pdf" --passivepopup "$count image(s) to pdfs converted!";

(this will convert images to pdf)

_________________________________________________________________

I added my custom service menus as .zip file for reference:

ServiceMenus.zip

 (this file contains the following service menus: open folder as root, open file as root, find in folder, convert image(s) to pdf(s), print documents, resize image(s), run in konsole, scale image(s) and send with kmail/thunderbird)

thunderbird is quite bitchy when it comes to send multiple images at once ^^  (but i somehow managed to get it work)

Don’t forget to restart dolphin after adding a new service menu 🙂

glhf !!!

One Response to “Add a custom service-menu to Dolphin (KDE SC)”



  1. Jimonade Says:

    thanks, this was helpful … https://sites.google.com/site/jimonade/home/kdeservicemenusandbashscripting