Is there a variable similar to $FILE or % to get the current page number from Zathura?

I'm trying to write a script to generate a text/markdown file with annotations from the pdf I'm reading. It would be executed using the :exec function. I'd like it to write the page where the annotation was made, like: Page 1 - "Annotation" Page 3 - "Another annotation"

Is it possible?

2 Answers 2


This is not possible from inside the exec function. However, Zathura provides this information over D-Bus, which is an IPC tool used in many Linux applications. I would recommend installing a D-Bus viewer (I used d-feet) and searching 'zathura' to see the properties and commands that are available --- there are several handy ones in there.

Importantly, the current page-number is available as a property that can be accessed through an external program. You should be able to use this information in combination with dbus-send (this answer on getting properties with dbus-send might be handy).

While I have not done it with dbus-send myself, these lines of Python with the dbus_next library did the trick for my use case, and might serve as a reference for appropriate Object & Interface names and paths.

from dbus_next.aio import MessageBus
bus = await MessageBus().connect()
introspection = await bus.introspect(f'org.pwmt.zathura.PID-{pid}', '/org/pwmt/zathura')
proxy_object = bus.get_proxy_object(f'org.pwmt.zathura.PID-{pid}', \
                                    '/org/pwmt/zathura', \
interface = proxy_object.get_interface('org.pwmt.zathura')
return await interface.get_pagenumber()
  • Hi! Thanks so much for the answer. Really cool idea. I will try and share with other people who wanted the same thing! Commented Mar 30, 2021 at 14:25

A couple of months after this was asked, the $PAGE variable was added, so you can now use that instead.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .