Tuesday, 31 March 2009

How-To: Create an Open as Root Service Menu in Dolphin and Konqueror (KDE4)

Not so long ago I put up a tutorial which included three useful tips for Konqueror 3.5.9 (KDE3), and one of them was how to create an Open as Root service menu for directories. In this how-to I will show how to accomplish the same thing in KDE4 this time, for both Dolphin and Konqueror.

One of the things which changed is the location where the .desktop file will be located, in the case of KDE4 this should be placed in the ~/.kde/share/kde4/services/ServiceMenus directory. In order to find out what are the directories where the service menus can be put you can run this command:

kde4-config --path services

Which, on my Kubuntu 9.04 system outputs:

embryo@kubu:~$ kde4-config --path services
/home/embryo/.kde/share/kde4/services/:/usr/share/kde4/services/

Also, the syntax of the desktop file changed a little. Here is a basic example of the .desktop file:

[Desktop Entry]
Type=Service
Icon=dolphin
Actions=OpenAsRoot
ServiceTypes=KonqPopupMenu/Plugin,inode/directory,inode/directory-locked

[Desktop Action OpenAsRoot]
Exec=kdesu dolphin %U
Icon=dolphin
Name=Open as Root

Save the file under a name like action_root.desktop inside ~/.kde/share/kde4/services/ServiceMenus and then right-click any directory inside Dolphin or Konqueror, go to Actions -> Open as Root and enter your user password (in Ubuntu) or root password in order to open that directory as root. I had to reload the tabs in Dolphin for the service menu to appear.

Here's how it looks like:

In Dolphin and KDE 4.2.1

In Konqueror and KDE 4.2.1

Additional resources
You may find these two tutorials very useful if you plan to create various service menus in KDE4: this tutorial from KDE TechBase and this forum discussion from KubuntuForums.net.

You can also download and explore a complete script hosted on www.kde-apps.org, called Root Actions Servicemenu.

Related articles
3 Popular Tips for Konqueror 3.5.9
Review: Dolphin 1.2.1 File Manager

3 comments:

Unknown said...

if this isn't already in svn, you should submit it for contribution :)

Karl said...

Very useful thanks.

Anonymous said...

Do you know where to publish the menus I created?