summaryrefslogtreecommitdiff
path: root/bin/zathura/zathura_attach
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2024-10-24 21:22:29 +0900
committerA Farzat <a@farzat.xyz>2024-11-04 21:22:29 +0900
commit6043242b6e13eab21c5ac7f39993bb6c1950f170 (patch)
tree1b043ed5720c457e17502e4772a8ca299d6e6620 /bin/zathura/zathura_attach
parent8c6b098c2b47ad70d3b161b3e16f1709038a0404 (diff)
downloaddotfiles-6043242b6e13eab21c5ac7f39993bb6c1950f170.tar.gz
dotfiles-6043242b6e13eab21c5ac7f39993bb6c1950f170.zip
Add custom zathura scripts
Diffstat (limited to 'bin/zathura/zathura_attach')
-rwxr-xr-xbin/zathura/zathura_attach23
1 files changed, 23 insertions, 0 deletions
diff --git a/bin/zathura/zathura_attach b/bin/zathura/zathura_attach
new file mode 100755
index 0000000..f9061d8
--- /dev/null
+++ b/bin/zathura/zathura_attach
@@ -0,0 +1,23 @@
+#!/usr/bin/env sh
+
+# Attach zathura to a running tabbed instance.
+
+# Keep in mind that one could also reattach windows through
+# xdotool windowreparent <source_id> <destination_id>
+# The source_id and destination_id can be obtained using
+# xwininfo -tree and looking at "Window id:"
+
+xids="$(xdotool search --class tabbed)"
+
+# If none are running, execute zathura_tabbed instead.
+[ -z "$xids" ] && exec zathura_tabbed "$@"
+
+# If only one is running, just attach to that.
+# Otherwise, filter to only one.
+if [ "$(printf "%s\n" "$xids" | wc -l)" -gt 1 ]
+then
+ xid="$(printf "%s" "$xids" | dmenu -p "Choose tabbed window to attach to:")"
+ [ -z "$xid" ] && { echo "No instance was chosen."; exit 1; } || xids="$xid"
+fi
+
+exec zathura -e "$xids" "$@"