summaryrefslogtreecommitdiff
path: root/ar/.local/bin/refreshbrowser
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-02-13 19:55:03 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-02-13 19:55:03 +0900
commit2f54119c00ce7717ab3a033afb4f25323f63c388 (patch)
treee1945f91521ed852ab92b3f112b9e988490e03b8 /ar/.local/bin/refreshbrowser
parenta426c345631249da9adc74880676fb6c21e4b782 (diff)
created bin/refreshbrowser
Diffstat (limited to 'ar/.local/bin/refreshbrowser')
-rw-r--r--ar/.local/bin/refreshbrowser42
1 files changed, 42 insertions, 0 deletions
diff --git a/ar/.local/bin/refreshbrowser b/ar/.local/bin/refreshbrowser
new file mode 100644
index 0000000..ef3809a
--- /dev/null
+++ b/ar/.local/bin/refreshbrowser
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+######################################################################
+# @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com)
+# @file : test.sh
+# @created : Wed 25 Mar 2020 05:49:29 PM
+#
+# @description : simple xdotool script used to reload browsers
+######################################################################
+
+browserclass="${qutebrowser:-firefox}"
+
+#=== FUNCTION ======================================================
+# NAME: moveto
+# DESCRIPTION: move to the center of the specified window id
+#=====================================================================
+moveto() {
+ geom=$(xdotool getwindowgeometry "${1}")
+ local=$(echo "${geom}" | awk NR==2 | cut -d: -f 2 | cut -d\( -f 1)
+ dimentions=$(echo "${geom}" | awk NR==3 | cut -d: -f 2 | cut -d\( -f 1 | cut -d, -f1)
+ x=$(echo "${local}" | cut -d, -f1)
+ y=$(echo "${local}" | cut -d, -f2)
+ w=$(echo "${dimentions}" | cut -dx -f1)
+ h=$(echo "${dimentions}" | cut -dx -f2)
+
+ xdotool mousemove $((x + w / 2)) $((y + h / 2))
+}
+
+# Save the current window
+cwid=$(xdotool getwindowfocus)
+# Find the browser window
+twid=$(xdotool search --onlyvisible --class "${browserclass}")
+[ -z "${twid}" ] && notify-send 'failed to determine browser window' && exit
+[ -z "${cwid}" ] && notify-send 'failed to determine current window' && exit
+
+moveto "${twid}"
+
+xdotool key F5
+
+moveto "${cwid}"
+
+# vim: set tw=78 ts=2 et sw=2 sr: