3

What would be the content of a .contract file in /usr/share/contractor for a menu entry like 'Mount iso'?

1
  • If somebody sees this and wants a context menu solution, an alternative is to install gnome-disk-utility (gnome-disks, Disks), which will provide 'Open With' > 'Disk Image Mounter'
    – user170
    Jul 5, 2015 at 18:35

2 Answers 2

6

Having installed gnome-disk-utility I already had Open With > Disc Image Mounter in context menu and a gnome-desk-image-mounter.desktop file in /usr/share/applications. Looking into that, I have created a .contract file that works with the same consequence (and so is a bit pointless, adding nothing, although answers the question):

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

With:

[Contractor Entry]
Name=Mount 
Icon=drive-removable-media
Description=Mount ISO file 
MimeType=application/x-cd-image;application/x-raw-disk-image
Exec=gnome-disk-image-mounter %f
Terminal=false
StartupNotify=false
Type=Application
NoDisplay=true
X-Ubuntu-Gettext-Domain=gnome-disk-utility

Just like with Disc Image Mounter, the image is not yet mounted, but added to the file manager sidebar list of drives and mounted from there

enter image description here

enter image description here

0

Can't guarantee that it'll work, but something along the lines of this:

[Contractor Entry]
Name=Mount ISO
Icon=ubiquity
Description=Mount ISO file to /mnt
MimeType=application/iso-image
Exec=pkexec mount -o loop %f /mnt

Some notes:

  • icons are found at /usr/share/icons/elementary. You can just put the appropriate name in.
  • the exec part is the relevant one. pkexec uses polkit to authorize an action that will require administrative privileges, such as using mount. If you want to put more effort into it, you may be able to use GNOME's mounting services to mount without using your password. %f will be replaced by the file's path.
  • since a contract only gets a file as argument, you can't specify the location. So you must either invoke a dialog (cheap solution would be a bash-invokable program like zenity) to ask for the location or use a default one, like /mnt
  • Maybe check the mime type, I don't have an ISO file handy to check it right now. Just right click and go to properties to find out.
5
  • Having put this in /usr/share/contractor/mount-iso.contract, I don't see any extra options when I right-click an ISO file. Maybe I need to restart.
    – Lewis Goddard
    Jul 5, 2015 at 18:23
  • Have you created it as such and it shows in context menu? I cannot see it. The mimetype is application/x-cd-image. (why do I need icons? Do you have icons in the context menu in Files?)
    – user170
    Jul 5, 2015 at 18:31
  • @LewisGoddard - creating a contract file doesn't need restart
    – user170
    Jul 5, 2015 at 18:31
  • the problem seems to be with the Exec= line. I have created a contractor that works, but one that ads nothing to what is already in Open With > Disc Image Mounter after installing gnome-disks. I have added an answer for that anyway.
    – user170
    Jul 5, 2015 at 18:44
  • @cipricus Changing the Mimetype got it to show in the menu, but I cannot get it to work still.
    – Lewis Goddard
    Jul 5, 2015 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.