From a864434259da61c467c65e2bf049496dec3736d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Fri, 29 Mar 2024 18:28:41 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(hypr):=20script=20to=20toggle?= =?UTF-8?q?=20floating=20states=20and=20control=20the=20size=20of=20the=20?= =?UTF-8?q?window?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/hypr/configs/binds.conf | 2 +- .config/hypr/scripts/toggle_floating | 31 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100755 .config/hypr/scripts/toggle_floating 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