Hi Alexander

On 2014-11-07 09:58:40, Alexander Baier wrote:
> On 2014-11-06 23:41 Sebastian Ramacher wrote:
> > On 2014-11-02 16:22:35, Alexander Baier wrote:
> >> Hello pwmt-devs!
> >> 
> >> Is there any way to tell a running zathura instance to change the page
> >> it is currently displaying? If I simply issue the following command
> >> line, a second instance of zathura is started. I, however, want the
> >> already running instance (displaying /tmp/test.pdf) to display page 5.
> >> 
> >>   zathura --page=5 /tmp/test.pdf
> >> 
> >> I want this to work on every PDF, which implies (IIUC) that using the
> >> synctex support is not an option here.
> >> 
> >> If the description above was not clear, just try the the above with
> >> evince or okular to see what I am talking about. Okular accepts an extra
> >> option "--unique" to toggle this behaviour. Evince just always does
> >> this - if you want it or not.
> >> 
> >> Is this achievable with the current zathura version? And if not, would
> >> you consider adding such a feature in a future version?
> >
> > The D-Bus interface offers a GotoPage method. You can do the same what
> > we do for --syntex-forward: look for a prg.pwmt.zathura instance that
> > has the correct file open (check the filename attribute) and run
> > GotoPage on it. The code that does this for --synctex-forward is located
> > in dbus-interface.c (iterate_instances_call_synctex_view).
> 
> Thank you for the pointer to the dbus interface.  My C experience,
> however, amounts to almost nothing which is why I probably won't try to
> implement this feature myself.

Here is a simple Python script that does what you want:

import dbus
import sys

filename=sys.argv[1]
page=sys.argv[2]

session = dbus.SessionBus()
for name in session.list_names():
    if not name.startswith("org.pwmt.zathura"):
        continue

    proxy = session.get_object(name, "/org/pwmt/zathura")
    zathura = dbus.Interface(proxy, "org.pwmt.zathura")
    properties = dbus.Interface(proxy, "org.freedesktop.DBus.Properties")

    ofilename = properties.Get("org.pwmt.zathura", "filename")
    if ofilename != filename:
        continue

    zathura.GotoPage(page)

Call it with python $foo.py /absolute/path.pdf page

> If you think this feature is use full, I can open a feature request on
> the bug tracker.  What do you think?

Maybe we should start a collection of scripts instead of putting them
all in the binary. I don't know yet.

Cheers
-- 
Sebastian Ramacher
_______________________________________________
zathura mailing list
zathura@lists.pwmt.org
http://lists.pwmt.org/mailman/listinfo/zathura

Reply via email to