From 25b49ee661b70ace8f5ed0c3dbaedc58ba5d747c Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Sun, 20 Oct 2024 19:07:38 +0530 Subject: [PATCH] fish: functions: Open PDFs in Zathura with fuzzel Taken from https://blog.akaisuisei.org/communicating-with-zathura-via-dbus.html --- fish/.config/fish/functions/opdf.fish | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 fish/.config/fish/functions/opdf.fish diff --git a/fish/.config/fish/functions/opdf.fish b/fish/.config/fish/functions/opdf.fish new file mode 100644 index 0000000..977d762 --- /dev/null +++ b/fish/.config/fish/functions/opdf.fish @@ -0,0 +1,21 @@ +function opdf --description 'Open PDF with fuzzel in existing Zathura' + set pdf (fd -H -e pdf "" ~/Study ~/Documents ~/Downloads | fuzzel --dmenu --width 128) + + if test -n "$pdf" + set zathuraid (dbus-send --session \ + --dest=org.freedesktop.DBus \ + --type=method_call \ + --print-reply \ + /org/freedesktop/DBus \ + org.freedesktop.DBus.ListNames | grep -o 'org.pwmt.zathura.PID-[0-9]*' | fuzzel --dmenu --width 128) + + if test -n "$zathuraid" + dbus-send --session \ + --dest=$zathuraid \ + --type=method_call \ + /org/pwmt/zathura \ + org.pwmt.zathura.ExecuteCommand \ + string:"open \"$pdf\"" + end + end +end