Files
dotfiles/hypr/scripts/toggle_floating
Timo 108ea36cca hyprland: port scripts off hyprlang hyprctl syntax
With the Lua config, `hyprctl dispatch` evaluates Lua rather than the
hyprlang dispatcher strings, and `hyprctl keyword` is refused outright
("can't work with non-legacy parsers"). Three scripts still used the old
forms and silently failed.

- toggle_floating (SUPER+W): rewritten around hl.dsp.window.{float,resize,
  center}. The Lua resize dispatcher takes absolute pixels only, so the
  70% is resolved against the logical size of the window's monitor, and
  fullscreen is left first since resize is a no-op while fullscreen.
  Floats every window at 70%x70% now, not just 50%x55% for kitty.
- performance: runtime overrides via `hyprctl eval hl.config{}`; drop the
  removed decoration:drop_shadow for decoration:shadow:enabled; read the
  gamemode flag from `getoption -j` (.bool), which the awk on line 2 had
  been picking the "set:" line out of.
- move_by_rules: movetoworkspace -> hl.dsp.window.move{workspace=N}.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01StGBghPW9Dm7z7uj2VNWHr
2026-09-04 15:21:05 +02:00

26 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# NOTE: with the Lua config, `hyprctl dispatch` evaluates Lua (hl.dispatch(...)),
# not the old hyprlang "togglefloating" / "resizeactive exact 70% 70%" strings.
# The Lua resize dispatcher only takes absolute x/y, so the percentage is
# resolved here against the logical size of the window's monitor.
PERCENT=70
eval "$(hyprctl activewindow -j | jq -r '"floating=\(.floating) fullscreen=\(.fullscreen) mon=\(.monitor)"')"
if [ "$floating" = "true" ]; then
hyprctl dispatch 'hl.dsp.window.float()'
exit
fi
read -r w h <<<"$(hyprctl monitors -j | jq -r --argjson m "$mon" --argjson p "$PERCENT" \
'.[] | select(.id == $m) | "\((.width / .scale * $p / 100) | round) \((.height / .scale * $p / 100) | round)"')"
# resizeactive is a no-op on a fullscreen window, so leave fullscreen first.
if [ "$fullscreen" != "0" ]; then
hyprctl dispatch 'hl.dsp.window.fullscreen({ mode = "fullscreen" })'
fi
hyprctl --batch "dispatch hl.dsp.window.float(); dispatch hl.dsp.window.resize({ x = ${w}, y = ${h} }); dispatch hl.dsp.window.center()"