0

I want to configure my Zathura so that when I open a document automatically the size of the page of pdf adjusts to the size of the window.

Practical example

If i close the Zathura like this:

enter image description here

When i open it again it stays the same size.

I want that when I open it again it automatically adjusts to the width of the window regardless of what state it had previously.

An example of what I mean is when you press the "s" it automatically adjusts to the entire window.

I tried this in zathurarc but doesn't work. Even with "width" but it does nothing regardless of the option I tried changing colors and worked so I know that zathura is reading the file correctly.

set adjust-open "best-fit"

Thx.

3 Answers 3

1

I was also looking for a solution to this, and like you, I couldn't get adjust-open to work either. I also couldn't find any discussion about this in the Zathura issue tracker. The other answer mentioning set adjust_window width doesn't work.

Unfortunately, I couldn't find a solution within Zathura itself, but after some fiddling with xdotool, I whipped up the following shell script:

#!/bin/sh
zathura "$@" & PID="$!"

while true; do
  window_id="$(xdotool search --onlyvisible --pid "$PID")"
  if [ -n "$window_id" ]; then
    xdotool windowactivate --sync "$window_id" windowfocus --sync "$window_id" \
      key s key --delay 0 g g
    break
  fi
done

This launches zathura and waits for a window to be created for that process ID. Then it activates and focuses the window, and sends the s keystroke to fit the document to the window width, followed by gg to go to the beginning. I don't like Zathura remembering the document position, but you can remove the second key --delay 0 g g if you don't need this.

I also have the following in my ~/.config/zathura/zathurarc file:

set window-height 3000
set window-width 3000

This starts the window "maximized".

Note that xdotool only works on X11, and I'm not aware of alternatives for Wayland.

This could be much easier if Zathura allowed the feedkeys shortcut function to be used outside of map, or any of the other shortcut functions for that matter.

Hope this helps someone else.

1
  • Thank @imiric very much for the answer, and I am also grateful for you taking the time and effort to write a detailed answer. Commented Jul 8, 2023 at 12:32
0

Edit your zathurarc (usually in .config/zathura/ folder) to include

set adjust_window width
0

In my case the set adjust-open width command did not work either. As I am using a tiled window manager and I plan to open pdf in half screen, the workaround I came up with, is to set the zoom-in and zoom-out options. I set a minimum zoom such that the document fills the window, and a maximum zoom such that it allows me to get rid of the margins.

In the ~/.config/zathura/zathurarc file:

set zoom-min 135
set zoom-max 175

Note: I think that zathura remembers last zoom value, so if you lower the minimum zoom and, after re-opening the file, you don't see any change, you have to zoom out manually.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.