diff --git a/hypr/scripts/move_by_rules b/hypr/scripts/move_by_rules index 637fbb9..3e21e5e 100755 --- a/hypr/scripts/move_by_rules +++ b/hypr/scripts/move_by_rules @@ -16,7 +16,7 @@ grep 'workspace' ~/.config/hypr/themes/luna/rules.conf | while IFS= read -r line # Compare the retrieved value with the active class of the window if echo "$active_class" | grep -E "$regex"; then #echo "The class matches the active class of the window. Workspace value to apply: $workspace_value" - hyprctl dispatch movetoworkspace "$workspace_value" + hyprctl dispatch "hl.dsp.window.move({ workspace = $workspace_value })" fi fi done diff --git a/hypr/scripts/performance b/hypr/scripts/performance index 9d90908..1818835 100755 --- a/hypr/scripts/performance +++ b/hypr/scripts/performance @@ -1,12 +1,18 @@ #!/usr/bin/env sh -HYPRGAMEMODE=$(hyprctl getoption animations:enabled | awk 'NR==2{print $2}') +# Toggles "game mode": strips animations/blur/shadows/gaps for max performance, +# and reloads the config to restore them. +# +# NOTE: with the Lua config `hyprctl keyword` is gone ("can't work with +# non-legacy parsers"); runtime overrides go through `hyprctl eval hl.config{}`. + +HYPRGAMEMODE=$(hyprctl getoption animations:enabled -j | jq -r '.bool') # Waybar performance FILE="$HOME/.config/waybar/style.css" sed -i 's/\/\* \(.*animation:.*\) \*\//\1/g' $FILE -if [ "$HYPRGAMEMODE" = 1 ]; then +if [ "$HYPRGAMEMODE" = true ]; then sed -i 's/^\(.*animation:.*\)$/\/\* \1 \*\//g' $FILE fi @@ -14,15 +20,20 @@ killall waybar waybar > /dev/null 2>&1 & # Hyprland performance -if [ "$HYPRGAMEMODE" = 1 ]; then - hyprctl --batch "\ - keyword animations:enabled 0;\ - keyword decoration:drop_shadow 0;\ - keyword decoration:blur:enabled 0;\ - keyword general:gaps_in 0;\ - keyword general:gaps_out 0;\ - keyword general:border_size 1;\ - keyword decoration:rounding 0" +if [ "$HYPRGAMEMODE" = true ]; then + hyprctl eval 'return hl.config({ + animations = { enabled = false }, + decoration = { + rounding = 0, + blur = { enabled = false }, + shadow = { enabled = false }, + }, + general = { + gaps_in = 0, + gaps_out = 0, + border_size = 1, + }, + })' exit fi diff --git a/hypr/scripts/toggle_floating b/hypr/scripts/toggle_floating index 3aefbf7..c090943 100755 --- a/hypr/scripts/toggle_floating +++ b/hypr/scripts/toggle_floating @@ -1,31 +1,25 @@ #!/bin/bash -floating=$(hyprctl activewindow -j | jq '.floating') -window=$(hyprctl activewindow -j | jq '.initialClass' | tr -d "\"") +# 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. -function toggle() { - width=$1 - height=$2 +PERCENT=70 - hyprctl --batch "dispatch togglefloating; dispatch resizeactive exact ${width} ${height}; dispatch centerwindow" -} +eval "$(hyprctl activewindow -j | jq -r '"floating=\(.floating) fullscreen=\(.fullscreen) mon=\(.monitor)"')" -function untoggle() { - hyprctl dispatch togglefloating -} +if [ "$floating" = "true" ]; then + hyprctl dispatch 'hl.dsp.window.float()' + exit +fi -function handle() { - width=$1 - height=$2 +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)"')" - if [ "$floating" == "false" ]; then - toggle "$width" "$height" - else - untoggle - fi -} +# 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 -case $window in -kitty) handle "50%" "55%" ;; -*) handle "70%" "70%" ;; -esac +hyprctl --batch "dispatch hl.dsp.window.float(); dispatch hl.dsp.window.resize({ x = ${w}, y = ${h} }); dispatch hl.dsp.window.center()"