diff options
Diffstat (limited to 'config/hypr/scripts/KeybindsLayoutInit.sh')
| -rwxr-xr-x | config/hypr/scripts/KeybindsLayoutInit.sh | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/config/hypr/scripts/KeybindsLayoutInit.sh b/config/hypr/scripts/KeybindsLayoutInit.sh index af81f62e..fd34f90e 100755 --- a/config/hypr/scripts/KeybindsLayoutInit.sh +++ b/config/hypr/scripts/KeybindsLayoutInit.sh @@ -2,8 +2,15 @@ # /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## # Initialize J/K keybinds to match the current default layout at startup -# Query current layout (master|dwindle) -LAYOUT=$(hyprctl -j getoption general:layout | jq -r '.str') +set -euo pipefail + +# Determine current layout (master|dwindle); be robust to null at startup +LAYOUT=$(hyprctl -j getoption general:layout | jq -r '.str // empty' 2>/dev/null || true) +if [ -z "${LAYOUT:-}" ]; then + # Fallback: parse non-JSON output (e.g., "str: dwindle") + LAYOUT=$(hyprctl getoption general:layout 2>/dev/null | awk -F'str:' 'NF>1 {gsub(/^ +| +$/,"",$2); print $2}') +fi +[ -z "${LAYOUT:-}" ] && exit 0 case "$LAYOUT" in master) @@ -20,8 +27,8 @@ case "$LAYOUT" in hyprctl keyword unbind SUPER,K hyprctl keyword unbind SUPER,O hyprctl keyword bind SUPER,J,cyclenext -hyprctl keyword bind SUPER,K,cyclenext,prev -# ensure SUPER+O togglesplit is available on dwindle + hyprctl keyword bind SUPER,K,cyclenext,prev + # ensure SUPER+O togglesplit is available on dwindle hyprctl keyword bind SUPER,O,togglesplit ;; *) |
