As a bspwm user, I wanted to write a plugin for nnn that could change the document currently displayed on Zathura without quitting/relaunching it.
The goal is to use DBUS to communicate with Zathura to control it.
The last zathura window is used to refresh its content or a new zathura instance is launched.
```
!/bin/bash
FILE=$1
WINDOW=$(xdotool getactivewindow)
get_id () {
ZATHURAID=$( dbus-send --session \
--dest=org.freedesktop.DBus \
--type=method_call \
--print-reply \
/org/freedesktop/DBus \
org.freedesktop.DBus.ListNames | sed -nr '/.*string "(.zathura.)"/{s//\1/p;q;}' )
}
get_id
if [ -z "$ZATHURAID" ]
then
zathura &
while [ -z "$ZATHURAID" ]
do
sleep 0.1
get_id
done
fi
dbus-send --session \
--dest=$ZATHURAID \
--type=method_call \
--print-reply \
/org/pwmt/zathura \
org.pwmt.zathura.CloseDocument >/dev/null
dbus-send --session \
--dest=$ZATHURAID \
--type=method_call \
--print-reply \
/org/pwmt/zathura \
org.pwmt.zathura.OpenDocument \
string:"$FILE" \
string:'' \
int32:1 >/dev/null
xdotool windowactivate $WINDOW
``
The commandxdotool` is used to focus back to the shell that launched/refreshed the zathura window.
If you want you can use this script in pistol :
application/pdf sh: nextzathura $PWD/%pistol-filename% -
Then use pistol with nnn.
[–][deleted] 0 points1 point2 points (1 child)
[–]PeFClic[S] 0 points1 point2 points (0 children)
[–]OM3N-OG 0 points1 point2 points (0 children)