February 9, 2014

Add Open As Root To Pantheon Files

You can add these options in the Files menu :



To do so right click Files in Plank and open New Window As Administrator.
Navigate to /usr/share/contractor.
Right click and Create New File > Empty File with the following content :
[Contractor Entry]
Name=Open folder as root
Icon=pantheon-files
Description=Open current folder as root privilege
MimeType=inode;
Exec=gksudo pantheon-files %U
Gettext-Domain=pantheon-files


Save the file as folder-openasroot.contract

If you copy and paste the content, make sure to make an extra keystroke e.g. hitting Space at the end of the last line. Otherwise the content will not be saved if auto-save is checked ( Scratch > Preferences > Save files when changed ). This a known bug.

For Open file as root create a new file in /usr/share/contractor with the following lines :
[Contractor Entry]
Name=Open file as root
Icon=scratch-text-editor
Description=open file as root with scratch
MimeType=text
Exec=gksudo scratch-text-editor %U
Gettext-Domain=scratch-text-editor


Save the file as scratch-openasroot.contract.

4 comments:

  1. Nice post! I didn't know you could do such things like this within the elementary pantheon-files app. I just created two contract files to integrate deja-dup backup and restore tool into pantheon-files. I always loved the feature that Gnome had with it's Deja-dup integration in to Nautilus and wanted to get the same in ElementaryOS. Now I have it and it's awesome.

    ReplyDelete
    Replies
    1. I've used these contractor files for months. I found it at http://elementaryforum.org/

      Delete
  2. I had to change 'gksudo' to 'sudo' for this to work.

    ReplyDelete
  3. that script works on Elementary Os Loki to add "open folder as root" option via "pkexec"



    create a contractor entry:

    sudo touch /usr/share/contractor/folder-openasroot.contract && gksudo scratch-text-editor /usr/share/contractor/folder-openasroot.contract

    then edit it like that:

    [Contractor Entry]
    Name=Open folder as root
    Icon=pantheon-files
    Description=Open folder as root
    MimeType=inode;
    Exec=pantheon-files-pkexec %U
    Gettext-Domain=pantheon-files" > /usr/share/contractor/openasroot.contract

    and then via terminal run that command:


    >sudo sh -c 'echo "#!/bin/sh
    pkexec \"/usr/bin/pantheon-files\" \"\$@\"" > /usr/bin/pantheon-files-pkexec'

    that's all. It's done!

    ReplyDelete

Note: Only a member of this blog may post a comment.