summaryrefslogtreecommitdiff
path: root/xwindowURI
diff options
context:
space:
mode:
authorepoch <epoch@enzo.thebackupbox.net>2021-10-25 07:45:50 +0000
committerepoch <epoch@enzo.thebackupbox.net>2021-10-25 07:45:50 +0000
commita847f39dc51ba0bf5acd61648946e88a06a57e2c (patch)
tree007831b52e35f41b6d1d5e0e8ed4870ca37476d5 /xwindowURI
parentd5fd6ce0bad91b1cd2e76515e1259fa6c93665a7 (diff)
downloaduritools-a847f39dc51ba0bf5acd61648946e88a06a57e2c.tar.gz
uritools-a847f39dc51ba0bf5acd61648946e88a06a57e2c.zip
added a program to generate a URI based on currently open X11 window data, then added it and a gopher-get, and another clipboard selection to top of list in urilaunch. switched to choose from dmenu
Diffstat (limited to 'xwindowURI')
-rwxr-xr-xxwindowURI35
1 files changed, 35 insertions, 0 deletions
diff --git a/xwindowURI b/xwindowURI
new file mode 100755
index 0000000..6e9235a
--- /dev/null
+++ b/xwindowURI
@@ -0,0 +1,35 @@
+#!/bin/sh
+if [ ! "$1" ];then
+ id="$(xwinID)"
+else
+ id="$1"
+fi
+
+class=$(xclass -id "$id")
+#echo "$class"
+
+case "$class" in
+mupdf)
+ basename="$(xwintitle "$id" | rev | cut '-d ' -f5- | rev)"
+ echo "b: $basename"
+ page="$(xwintitle "$id" | tr ' ' '\n' | grep '[0-9][0-9]*/[0-9][0-9]*' | cut -d/ -f1)"
+ echo "$page"
+ for PID in $(pgrep mupdf);do
+ argv1="$(cat /proc/$PID/cmdline | tr '\0' '\n' | sed -n 2p)"
+ cd "$(readlink /proc/$PID/cwd)"
+ abspath="$(normalpath "$argv1")"
+ echo "a: $abspath"
+ echo "b: $basename"
+ if [ "$(basename "$abspath")" = "$basename" ];then
+ printf "file://%s#page=%s\n" "$(uriescape "$abspath")" "$page"
+ exit 0
+ fi
+ done
+ ;;
+Navigator)
+ xwintitle "$id" | rev | cut '-d ' -f4 | rev
+ ;;
+*)
+ echo "class: $class"
+ ;;
+esac