0

I love zathura to read my PDF but there is an important feature I am missing.

How can I open a copy on the current file (in another instance of zathura)?

Thanks for your help!

Update (solution): For my version of zathura (zathura 0.5.2), I just need to add the line

map <C-o> exec "zathura $FILE"

In .config/zathura/zathurarc

I thanks renzev whose commentary helped me a lot to find this solution!

1 Answer 1

0

I love Zathura too! I only started using it recently, so I am not sure if this is the best way to accomplish what you want, but try adding the following to ~/.config/zathura/zathurarc (create the file if it doesn't exist):

map <C-o> feedkeys ":exec zathura $FILE<Return>"

This will map CTRL+o to spawn a new instance of Zathura with the current file.

If you want to actually copy your file and open the copy, as opposed to opening the same file twice, then you could use some inline scripting:

map <C-o> feedkeys ":exec sh -c 'NEW=$(zenity --file-selection --save --filename $FILE) && cp $FILE $NEW && zathura $NEW'<Return>"

This will display a file dialog asking where you want to save the copy and then open the copy. Note that the zentiy program is required. Also please note that this will break in case your filename has spaces. If you want it to work for files with spaces, you could create a separate shell script (called something like zathura_open_copy.sh) to do the copying and opening:

#!/bin/bash
set -e
OLD=$@
NEW=$(zenity --file-selection --save --filename "$OLD")
cp "$OLD" "$NEW"
zathura "$NEW" & disown

And then the zathurarc line would be:

map <C-o> feedkeys ":exec zathura_open_copy.sh $FILE<Return>"

If zathura is installed in a weird way (e.g. not in $PATH, or though flatpak), change zathura in the above commands to however you would normally launch zathura from the terminal.

I was able to come up with this hanks to this answer

2
  • Thanks for this interesting and detailled answer! Sadly, it doesn't work for me with zathura 0.5.2, the error message is "pattern no found". I think i understood why : using feedkeys seems to launch the following command "/exec zathura ...." instead of ":exec zathura...". I saw that by just removing the <Return> in the command, in order to show the command. At the contrary, using "focus_inputbar" will indeed send the ":" but seems to no accept a "<Return>".
    – mahaaaham
    Commented Nov 28, 2023 at 11:31
  • 1
    I found that with my version, the solution is even simpler! I just added "map <C-o> exec "zathura $FILE"!
    – mahaaaham
    Commented Nov 28, 2023 at 11:39

You must log in to answer this question.

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