aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/Tak0-Autodispatch.sh
diff options
context:
space:
mode:
Diffstat (limited to 'config/hypr/scripts/Tak0-Autodispatch.sh')
-rwxr-xr-xconfig/hypr/scripts/Tak0-Autodispatch.sh69
1 files changed, 50 insertions, 19 deletions
diff --git a/config/hypr/scripts/Tak0-Autodispatch.sh b/config/hypr/scripts/Tak0-Autodispatch.sh
index 034a6402..cabe1672 100755
--- a/config/hypr/scripts/Tak0-Autodispatch.sh
+++ b/config/hypr/scripts/Tak0-Autodispatch.sh
@@ -71,6 +71,18 @@ fi
echo "=== Deploy '$CMD' → WS $TARGET_WS @ $(date) ===" >>"$LOGFILE"
+# Detect active Hyprland config mode
+config_home="${XDG_CONFIG_HOME:-$HOME/.config}"
+hypr_dir="$config_home/hypr"
+lua_entry="$hypr_dir/hyprland.lua"
+legacy_lua_entry="$config_home/hyprland.lua"
+
+if [[ -f "$lua_entry" || -f "$legacy_lua_entry" ]]; then
+ hypr_config_mode="lua"
+else
+ hypr_config_mode="conf"
+fi
+
# ─────────────────────────────────────────────────────────────────────────────
# 1️⃣ HYPRLAND READINESS GATE
# ─────────────────────────────────────────────────────────────────────────────
@@ -91,11 +103,17 @@ done
cleanup() {
echo "Cleanup: removing temporary capture rules and initialWorkspace at $(date)" >>"$LOGFILE"
- hyprctl keyword windowrulev2 "unset, initialClass:.*" >>"$LOGFILE" 2>&1 || true
- for RULE in "${CAPTURE_RULES[@]}"; do
- echo "Cleanup: removing temporary capture rule: $RULE" >>"$LOGFILE"
- hyprctl keyword windowrulev2 "unset, $RULE" >>"$LOGFILE" 2>&1 || true
- done
+ if [[ "$hypr_config_mode" == "lua" ]]; then
+ # In Lua mode, we try to nullify the temporary rules or trigger a reload
+ # Since we don't have a reliable 'unset' API via eval yet, we reload
+ hyprctl reload >>"$LOGFILE" 2>&1 || true
+ else
+ hyprctl keyword windowrulev2 "unset, initialClass:.*" >>"$LOGFILE" 2>&1 || true
+ for RULE in "${CAPTURE_RULES[@]}"; do
+ echo "Cleanup: removing temporary capture rule: $RULE" >>"$LOGFILE"
+ hyprctl keyword windowrulev2 "unset, $RULE" >>"$LOGFILE" 2>&1 || true
+ done
+ fi
}
trap cleanup EXIT INT TERM ERR
@@ -105,28 +123,35 @@ trap cleanup EXIT INT TERM ERR
# ─────────────────────────────────────────────────────────────────────────────
# Temporarily forces ALL windows (initialClass:.*)
# onto the target workspace.
-#
-# Protects against ultra-fast helpers:
-# • gpu-process
-# • renderer
-# • steamwebhelper
echo "Applying temporary initialWorkspace capture (initialClass:.*)" >>"$LOGFILE"
-hyprctl keyword windowrulev2 \
- "initialWorkspace $TARGET_WS silent, initialClass:.*" \
- >>"$LOGFILE" 2>&1 || true
+if [[ "$hypr_config_mode" == "lua" ]]; then
+ # Note: Using workspace property in hl.window_rule as a best-effort equivalent
+ hyprctl eval "hl.window_rule({ name = 'autodispatch-nuclear', match = { class = '.*' }, workspace = '$TARGET_WS' })" >>"$LOGFILE" 2>&1 || true
+else
+ hyprctl keyword windowrulev2 \
+ "initialWorkspace $TARGET_WS silent, initialClass:.*" \
+ >>"$LOGFILE" 2>&1 || true
+fi
# ─────────────────────────────────────────────────────────────────────────────
# 3️⃣.1 OPTIONAL CLASS-BASED PRE-CAPTURE
# ─────────────────────────────────────────────────────────────────────────────
# Additional precision rules.
-# Useful for Electron / Steam multi-process hell.
for RULE in "${CAPTURE_RULES[@]}"; do
echo "Applying temporary capture rule: $RULE" >>"$LOGFILE"
- hyprctl keyword windowrulev2 \
- "initialWorkspace $TARGET_WS silent, $RULE" \
- >>"$LOGFILE" 2>&1 || true
+ if [[ "$hypr_config_mode" == "lua" ]]; then
+ # Attempt to parse rule string into Lua table if it matches class:pattern
+ if [[ "$RULE" =~ class:\^\((.*)\)\$ ]]; then
+ local class_pat="${BASH_REMATCH[1]}"
+ hyprctl eval "hl.window_rule({ name = 'autodispatch-$class_pat', match = { class = '$class_pat' }, workspace = '$TARGET_WS' })" >>"$LOGFILE" 2>&1 || true
+ fi
+ else
+ hyprctl keyword windowrulev2 \
+ "initialWorkspace $TARGET_WS silent, $RULE" \
+ >>"$LOGFILE" 2>&1 || true
+ fi
done
# ─────────────────────────────────────────────────────────────────────────────
@@ -158,9 +183,14 @@ echo "App gate name: $APP_NAME" >>"$LOGFILE"
sleep 1.5
-#!TO-DO: Release the nuclear option ASAP
echo "Releasing ultra-early wide capture" >>"$LOGFILE"
-hyprctl keyword windowrulev2 "unset, initialClass:.*" >>"$LOGFILE" 2>&1 || true
+if [[ "$hypr_config_mode" == "lua" ]]; then
+ # In Lua mode, we rely on the supervision loop for precision after launch
+ # and cleanup will handle the rest.
+ :
+else
+ hyprctl keyword windowrulev2 "unset, initialClass:.*" >>"$LOGFILE" 2>&1 || true
+fi
# ─────────────────────────────────────────────────────────────────────────────
# 5️⃣ SUPERVISION LOOP (AUTHORITATIVE PHASE)
@@ -221,6 +251,7 @@ while ((SECONDS < END_TIME)); do
if ((MATCH)) && [[ -z "${SEEN[$ADDR]-}" ]]; then
echo "Placing window $ADDR (pid $PID, class $CLASS) → WS $TARGET_WS" >>"$LOGFILE"
+ # Dispatch works the same in both modes
hyprctl dispatch movetoworkspacesilent \
"$TARGET_WS,address:$ADDR" >>"$LOGFILE" 2>&1 || true
SEEN[$ADDR]=1
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage