How To: Add “Open As Root” Entry Manually To KDE’s Dolphin File Manager?

Add custom action that allows you to open a Dolphin file manager iteration with root privileges from within a graphic interface. Linux and in particular KDE are so customizable that you’ll have hard time to find a feature that you like which isn’t already present or easily add-able as an extension. However, on the rare

Updated Aug 29, 2017How To's
Dolphin custom action open as root

Linux and in particular KDE are so customizable that you’ll have hard time to find a feature that you like which isn’t already present or easily add-able as an extension.

However, on the rare occasions where the given supply isn’t quite to your satisfaction, there’s always the good old method of paving your own road, so to speak.

In the following, I shall demonstrate how to create a custom action (as per Xfce) that will let you launch a root-privileged Dolphin from within a non-privileged one.

Note that although I’m using it to create a “Open As Root” entry in the right-click context menu, the same method can apply to any other custom action you may desire.

Requirements

  • Dolphin file manager (obviously).
  • kdesu – if it’s not installed by default, install it.

[Update 15/05/2017]: users with KDE Applications 17.04 and above may not be able to launch Dolphin as root anymore, please see: KDE Plasma Canceling “Run As Root” Is Now Taking Effect – for more details. (but before you do, please read the line below)

[Update 27/08/2017]: The above mentioned limit can be bypassed, read here how.

Create The Entry

In KDE 5 there are basically two places where Plasma, your desktop environment, will “look” for custom actions by default:

  1. ~/.local/share/kservices5/ServiceMenus/
  2. /usr/share/kservices5/ServiceMenus/

The difference is that the first one will only apply to a specific user whereas the latter will apply to all users.

Note: if any of the above paths does not exist on your system –

  1. Make sure that your distribution doesn’t use a customized path.
  2. Create the path.

Now, navigate into the location you wish to create the custom action in. (Remember, use location #1 for only your user and #2 if you want the custom action to be available for evryone that uses the system!)

Create a text file and name it an easily to remember name with the suffix “.desktop”, like this: root_dolphin.desktop.

Copy paste the following text inside it:

[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
MimeType=inode/directory;
Actions=openRootDolphinHere;
X-KDE-AuthorizeAction=shell_access

[Desktop Action openRootDolphinHere]
Name=Open Root Dolphin Here
TryExec=kdesu
Exec=kdesu dolphin %U
Icon=folder-red

Open Dolphin as root service text

Open Dolphin as root service text

Save and close the file.

Restart Dolphin, right click and check whether your newly created entry is inside Actions.

If not, click Control on the top bar > Configure Dolphin… > Services > check Open Root Dolphin Here then click OK.

Open Dolphin as root check in services

Open Dolphin as root check in services

Right click, and there you have it inside Actions item.