Discussion:
[zathura] Set the page of a running zathura instance from the command line
Alexander Baier
2014-11-02 15:22:35 UTC
Permalink
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?

Kind regards,
--
Alexander Baier
Sebastian Ramacher
2014-11-06 22:41:53 UTC
Permalink
Post by Alexander Baier
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).

Cheers
--
Sebastian Ramacher
Alexander Baier
2014-11-07 08:58:40 UTC
Permalink
Post by Sebastian Ramacher
Post by Alexander Baier
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.

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

Regards,
--
Alexander Baier
Sebastian Ramacher
2014-11-10 00:00:59 UTC
Permalink
Hi Alexander
Post by Alexander Baier
Post by Sebastian Ramacher
Post by Alexander Baier
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
Post by Alexander Baier
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
Loading...