summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xopen-webui-ask44
1 files changed, 44 insertions, 0 deletions
diff --git a/open-webui-ask b/open-webui-ask
new file mode 100755
index 0000000..f2ce9c3
--- /dev/null
+++ b/open-webui-ask
@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+#
+# use xdotool to click the microphone icon on open-webui, then submit on any
+# button press and return the the previous window
+#
+# this assumes that:
+# - open-webui is the front tab of some firefox window, that way
+# we can select it with --name. maybe just keep it in its own window, or doing
+# some pwa thing and installing it
+# - the web app is already open to an existing chat, so the message box is at
+# the bottom
+# - the window is not super wide, so the buttons hug the bottom-right corner
+# rather than floating in the middle somewhers
+
+# store active window
+original_window_id=$(xdotool getactivewindow)
+
+# switch to open webui in firefox
+open_webui=$(xdotool search --name "open webui")
+xdotool windowactivate $open_webui
+
+# get window geometry as shell variables
+eval $(xdotool getwindowgeometry --shell $open_webui)
+click_x=$(($WIDTH - 130))
+click_y=$(($HEIGHT - 67))
+
+# click the microphone icon
+xdotool mousemove --window $WINDOW $click_x $click_y
+
+# delay bc sometimes it takes a moment for the window to update i guess
+sleep 0.5
+xdotool click 1
+
+# wait for keypress on keyboard 8, which is my voyager keyboard
+xinput test 8 | while read line; do
+ if [[ "$line" == *"key press"* ]]; then
+ # click the stop button
+ click_x2=$(($WIDTH - 60))
+ xdotool mousemove --window $WINDOW $click_x2 $click_y click 1
+ # switch back to original window
+ xdotool windowactivate $original_window_id
+ break
+ fi
+done