summaryrefslogtreecommitdiff
path: root/open-webui-ask
blob: f2ce9c38df46e67125b2cee31b8ebf3c75a46b1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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