diff --git a/.config/hypr/configs/binds.conf b/.config/hypr/configs/binds.conf index 7085c961..a4f130b4 100644 --- a/.config/hypr/configs/binds.conf +++ b/.config/hypr/configs/binds.conf @@ -6,7 +6,7 @@ bindm = SUPER, mouse:273, resizewindow bind = SUPER, Q, killactive, bind = SUPERCTRL, R, exec, pkill waybar || waybar bind = SUPERCTRL, M, exit -bind = SUPER, A, exec, hyprctl dispatch togglefloating && hyprctl dispatch centerwindow 1 +bind = SUPER, A, exec, ~/.config/hypr/scripts/toggle_floating bind = SUPER, P, pseudo bind = SUPER, F, fullscreen, 0 bind = SUPER, Z, exec, pypr zoom diff --git a/.config/hypr/scripts/toggle_floating b/.config/hypr/scripts/toggle_floating new file mode 100755 index 00000000..75e41954 --- /dev/null +++ b/.config/hypr/scripts/toggle_floating @@ -0,0 +1,31 @@ +#!/bin/bash + +floating=$(hyprctl activewindow -j | jq '.floating') +window=$(hyprctl activewindow -j | jq '.initialClass' | tr -d "\"") + +function toggle() { + width=$1 + height=$2 + + hyprctl --batch "dispatch togglefloating; dispatch resizeactive exact ${width} ${height}; dispatch centerwindow" +} + +function untoggle() { + hyprctl dispatch togglefloating +} + +function handle() { + width=$1 + height=$2 + + if [ "$floating" == "false" ]; then + toggle "$width" "$height" + else + untoggle + fi +} + +case $window in +kitty) handle "55%" "60%" ;; +*) handle "75%" "80%" ;; +esac