Elementary OS File Manager – Add ‘Open Folder as Root’ to Context Menu

elementary-osfile-managerfilesmenu

Here it is the solution in order to add the 'open terminal here' into the context menu of Elementary OS' file manager (generically called 'Files' – the executable is pantheon-files).

For that specific demand, the idea is to create the file /usr/share/contractor/terminal.contract and add something like

[Contractor Entry]
Name=Open Terminal here
Icon=terminal
Description=Open Terminal here
MimeType=inode;application/x-sh;application/x-executable;
Exec=pantheon-terminal -d %U
Gettext-Domain=pantheon-terminal

But how to adapt that and have a model to add other commands, namely – following my order of priorities – 'open folder as root'?

Best Answer

In order to create 'Open folder as root' context menu command - and in order to create any new such command - a new *.contract file has to be created in /usr/share/contractor.

To create the file in gedit:

sudo gedit /usr/share/contractor/Open_as_admin.contract

For 'Open folder as root' - that file would have to contain something like

[Contractor Entry]
Name=Open folder as root
Icon=gksu-root-terminal
Description=Open folder as root
MimeType=inode;application/x-sh;application/x-executable;
Exec=gksudo pantheon-files -d %U
Gettext-Domain=pantheon-files

(but no icon appears in te context menu anyway)

enter image description here

Related Question