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.

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.

COMMENTS (beta 4)

?
Add your comment here...
7
Jacques 5 mons ago
I did everything as explained, but every time I click 'Open Root Dolphin Here', I receive:
'The process for the file protocol died unexpectedly.' and the folders panel is empty, whichever folder I try.
6
TommyLinux 5 mons ago
Martin from kde, removed open as root in kde, this no longer works...sad day for kde
5
LinuxComp 7 mons ago
Dolphin could not start such way for me. But adding "dbus-launch" to exec command solves this:

Exec=kdesu dbus-launch dolphin %U


For kdesu to ask your user's password instead of root's password, run:

$ kwriteconfig5 --file kdesurc --group super-user-command --key super-user-command sudo


Alternatively, you can install kdesudo and use it instead:

Exec=kdesudo dbus-launch dolphin %U

4
Doug 9 mons ago
I found an old instruction from pclos forum Nov 22, 2008 12:10 PM, "Superuser access to Dolphin or Konqueror." It took some futzing around, but I seem to have gotten it to work.
Thanx for your assistance anyway. 
3
doug 9 mons ago
I'm not sure I have the "path" set. Where and how should it be done?
2
doug 9 mons ago
I had corrected the typo in the filename. I checked the file and found a typo in it, and fixed that, but still no joy. Here is the file, as it exists now: root_dolphin.desktop:

[doug@linux1 ~]$ cd /usr/share/kservices5/ServiceMenus/
[doug@linux1 ServiceMenus]$ cat root_dolphin.desktop
[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

Perhaps there is another typo that I can't see?
Thanx for your reply.

1
doug 9 mons ago
Did everything according to your instructions, but "Services" does not show the file, which I
called "root_dolphin.desktop"  in the directory you told me to, as you suggested. Carefully checked the file I created with nano, and it reads OK, but the final check in Actions doesn't show the command. Now what? Please help!
1
Liron 9 mons ago doug
Hi doug,
Have you copied the file name from this article by any chance? I had a typo with file's name suffix (I wrote dekstop instead of desktop).
If so, that's where the problem lies, correct the suffix and it should work.

Also, if the file name is correct, make sure the action is shown under Services in dolphin's configuration and that it's checked.

More In Linux