6

Upon opening a pdf in evince and then making a change to that document (recompiling it in LaTeX), evince will automatically refresh to the latest version of the document.

mupdf however does not do this: it keeps showing the version I originally opened. The latest version can be loaded with the r command, but is there a way to make mupdf behave like evince in that respect? The manual doesn’t mention this.

Philipp
  • 549

3 Answers3

11

Poke mupdf with a HUP signal after the document changes (e.g. after recompiling it, or use entr or something to note the filesystem change)

pkill -HUP mupdf

or with more complication one might write an open-or-signal-mupdf script.

thrig
  • 34,938
  • 1
    Thanks for your answer. Since I’m using latexmk (but didn’t mention it in the question), I now found this answer, which is exactly what I was looking for: https://superuser.com/questions/707483/how-do-i-use-latexmk-with-mupdf-as-the-pdf-previewer – Philipp Feb 22 '18 at 16:34
  • Looks like the user's GitHub account gets deleted, but the script can be found at a fork of the repository https://github.com/wangfuli217/scripts/blob/master/misc/mopen – user202729 Mar 26 '23 at 02:10
4

Adding a little to thrig's answer, this is what I came up with:

f=file.pdf; mupdf $f & while inotifywait -e close_write $f; do pkill -HUP mupdf; done

This will open a pdf file with mupdf and refresh whenever the pdf is written to.

the idea to use inotify came from this answer

0

Here's mine:

#!/usr/bin/fish

set f $argv[1] mupdf $f & set mu_pid $last_pid while true inotifywait --event close_write $f & set in_pid $last_pid wait --any $mu_pid $in_pid if not jobs --query $mu_pid exit 0 end kill -HUP $mu_pid end

It only refreshes the specific PID of the instance of mupdf whose file was actually changed, rather than all instances.