feat(hypr): script to toggle floating states and control the size of the window

This commit is contained in:
Sergio Laín 2024-03-29 18:28:41 +01:00
parent b126fe5bb0
commit a864434259
No known key found for this signature in database
GPG key ID: 14C9B8080681777B
2 changed files with 32 additions and 1 deletions

View file

@ -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

View file

@ -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