Search code examples
dbusquicklookgnome-3nautilus

Gnome 3: Call sushi, the Nautilus quick file previewer via DBus


In Gnome 3, Nautilus has a new file previewer called Sushi. You can select a file in Nautilus, hit the spacebar and it will show a quick preview. This is very similar to what Quick Look (Preview) on OSX does. Quick Look has a command line interface that allows you to use Quick Look from inside your own application. Sushi does not appear to allow this.

It appears the only way to call sushi it via dbus. (If you know how to call it via the cmd line, even better) I found sushi's source for where it registers its dbus messages but cannot figure out how to call it.

Here's what I tried:

> qdbus org.gnome.NautilusPreviewer /org/gnome/NautilusPreviewer org.gnome.NautilusPreviewer.ShowFile /foo/bar/baz.png 0x1c00010 0
Error: org.gnome.gjs.JSError.Error
Argument 'parent' (type interface) may not be null

I'm a novice when it comes to dbus, so maybe I'm missing something obvious

> dbus-send --print-reply --dest=org.gnome.NautilusPreviewer /org/gnome/NautilusPreviewer org.gnome.NautilusPreviewer.ShowFile string:"/foo/bar/baz.png" uint32:0x1c00010 uint32:1
Error org.freedesktop.DBus.Error.InvalidArgs: Type of message, '(suu)', does not match expected type '(sib)'

Solution

  • Try this:

    dbus-send --print-reply --dest=org.gnome.NautilusPreviewer /org/gnome/NautilusPreviewer org.gnome.NautilusPreviewer.ShowFile string:"file:///foo/bar/baz.png" int32:0 boolean:false
    

    Your second error means you used incorrect types: you should use string, int32 and boolean (sib), not string and two unsigned integers (suu).

    Also please note that you should use URI, not raw filename - just add file:// scheme prefix.

    Second parameter should be xid of Window you want to show your preview over. But 0 works for me.