Friday, May 23, 2014

GNOME Nautilus scripts

On GNOME Nautilus toolbar I've registered how to tweak the toolbar.
There I've mentioned one limitation of the Create Folder button:
It can't create a ZFS file system.
It can only create a mere directory.
Of course I won't develop a GNOME extension right now (maybe in the future).
Instead, I'll provide a (perhaps ugly) workaround using GNOME Nautilus script.

NOTE
I assume that judicious ZFS delegated permissions are in place. 
A non-privileged user will be able to perform the operation.
Also see zfs_allow(1M) for additional detail.

I also assume that some SSH transparent authentication is in place.
That's because in most cases the operation is typically remote.
By the way, environment variables should help detect this.

Initially, when there's no GNOME Nautilus scripts, things are hidden.
For instance, on the File menu there's no Scripts menu item.


And context menus won't show Scripts either:


But as soon as executable scripts are created it will appear.

$ cd ~/.gnome2/nautilus-scripts/
$ touch create-zfs-filesystem; chomd a+x !!*

$ cat create-zfs-filesystem
#!/bin/bash

zenity --info --text="Hello, world!"

From that point on you can easily remember the scripts folder location.
If you select Scripts | Open Scripts Folder you'll see the following:
(under File or context menus where meaningful)


Expanding the details helps remembering some environment variables.
Most (there are exceptions for remote locations) are available to any script:


 
By the way, check this other post on how to enable the handy Nautilus context terminals.