commit 3733a29db04f6468c673b4d65988d49dd544888b
parent 4f7ec4fd621eb5245ec08a2357924da52304a674
Author: Henry Unite <unitehenry@gmail.com>
Date: Wed, 1 Jul 2026 04:24:09 +0000
refactor: scripts
Diffstat:
6 files changed, 125 insertions(+), 54 deletions(-)
diff --git a/scripts/chromium b/scripts/chromium
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+cleanup() {
+ pkill -f chromium || true
+}
+
+trap cleanup EXIT
+
+nohup chromium --user-data-dir="$(pwd)/chrome-profile" --remote-debugging-port=9222 > chromium.out &
+
+sleep infinity
diff --git a/scripts/connect b/scripts/connect
@@ -2,72 +2,33 @@
set -euo pipefail
-declare -a SSH_PIDS
+declare -a PIDS
cleanup() {
- sudo docker rm -f guacamole;
- sudo docker rm -f guacd;
-
- pkill -f opencode
- pkill -f wayvnc;
- pkill -f chromium;
-
- hyprctl output remove Virtual-1
-
- for pid in "${SSH_PIDS[@]}"; do
+ for pid in "${PIDS[@]}"; do
if kill -0 "$pid" 2>/dev/null; then
- echo " Killing SSH PID $pid"
- kill "$pid" 2>/dev/null || true
- wait "$pid" 2>/dev/null || true
+ echo " Killing $pid"
+ kill "$pid" 2>/dev/null || true
+ wait "$pid" 2>/dev/null || true
fi
done
}
trap cleanup EXIT
-sudo docker run \
- --add-host host.docker.internal:host-gateway \
- -p 4822:4822 \
- --name guacd \
- -d guacamole/guacd
-
-sudo docker run --name guacamole \
- --add-host host.docker.internal:host-gateway \
- -e GUACD_HOSTNAME=host.docker.internal \
- -e LOG_LEVEL="debug" \
- -v "$(pwd)/guacamole:/etc/guacamole" \
- -d \
- -p 8080:8080 guacamole/guacamole
-
-hyprctl output create headless Virtual-1
-
-nohup wayvnc 0.0.0.0 5900 "Virtual-1" > wayvnc.out &
-
-nohup chromium --user-data-dir="$(pwd)/chrome-profile" --remote-debugging-port=9222 > chromium.out &
-
-nohup opencode web --hostname=0.0.0.0 --port=4090 > opencode.out &
-
-sleep 2
-
-CLIENTS=$(hyprctl clients -j | jq -r '.[] | select(.class | test("chromium"; "i")) | .address')
-
-COUNT=$(echo "$CLIENTS" | wc -l)
-
-echo "Found $COUNT Chromium window(s). Moving them to Virtual-1..."
+./scripts/guacamole &
+PIDS+=($!)
-for ADDR in $CLIENTS; do
- echo "→ Moving window $ADDR"
- hyprctl dispatch focuswindow address:"$ADDR" >/dev/null
- hyprctl dispatch movewindow mon:Virtual-1 >/dev/null
- sleep 0.2
-done
+./scripts/chromium &
+PIDS+=($!)
-hyprctl keyword monitor Virtual-1,preferred,auto,1
+./scripts/opencode &
+PIDS+=($!)
-ssh -f -N -R 8080:127.0.0.1:8080 root@142.93.14.238
-SSH_PIDS+=($!)
+./scripts/virtual &
+PIDS+=($!)
-ssh -f -N -R 4090:127.0.0.1:4090 root@142.93.14.238
-SSH_PIDS+=($!)
+./scripts/tunnel &
+PIDS+=($!)
sleep infinity
diff --git a/scripts/guacamole b/scripts/guacamole
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+cleanup() {
+ sudo docker rm -f guacamole || true
+ sudo docker rm -f guacd || true
+}
+
+trap cleanup EXIT
+
+sudo docker run \
+ --add-host host.docker.internal:host-gateway \
+ -p 4822:4822 \
+ --name guacd \
+ -d guacamole/guacd
+
+sudo docker run --name guacamole \
+ --add-host host.docker.internal:host-gateway \
+ -e GUACD_HOSTNAME=host.docker.internal \
+ -e LOG_LEVEL="debug" \
+ -v "$(pwd)/guacamole:/etc/guacamole" \
+ -d \
+ -p 8080:8080 guacamole/guacamole
+
+sleep infinity
diff --git a/scripts/opencode b/scripts/opencode
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+cleanup() {
+ pkill -f opencode || true
+}
+
+trap cleanup EXIT
+
+nohup opencode web --hostname=0.0.0.0 --port=4090 > opencode.out &
+
+sleep infinity
diff --git a/scripts/tunnel b/scripts/tunnel
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+declare -a SSH_PIDS
+
+cleanup() {
+ for pid in "${SSH_PIDS[@]}"; do
+ if kill -0 "$pid" 2>/dev/null; then
+ echo " Killing SSH PID $pid"
+ kill "$pid" 2>/dev/null || true
+ wait "$pid" 2>/dev/null || true
+ fi
+ done
+}
+
+trap cleanup EXIT
+
+ssh -N -R 8080:127.0.0.1:8080 root@142.93.14.238 &
+SSH_PIDS+=($!)
+
+ssh -N -R 4090:127.0.0.1:4090 root@142.93.14.238 &
+SSH_PIDS+=($!)
+
+sleep infinity
diff --git a/scripts/virtual b/scripts/virtual
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+cleanup() {
+ pkill -f wayvnc || true
+ hyprctl output remove Virtual-1 || true
+}
+
+trap cleanup EXIT
+
+hyprctl output create headless Virtual-1
+
+nohup wayvnc 0.0.0.0 5900 "Virtual-1" > wayvnc.out &
+
+sleep 2
+
+CLIENTS=$(hyprctl clients -j | jq -r '.[] | select(.class | test("chromium"; "i")) | .address')
+
+COUNT=$(echo "$CLIENTS" | wc -l)
+
+echo "Found $COUNT Chromium window(s). Moving them to Virtual-1..."
+
+for ADDR in $CLIENTS; do
+ echo "→ Moving window $ADDR"
+ hyprctl dispatch focuswindow address:"$ADDR" >/dev/null
+ hyprctl dispatch movewindow mon:Virtual-1 >/dev/null
+ sleep 0.2
+done
+
+hyprctl keyword monitor Virtual-1,preferred,auto,1
+
+sleep infinity