feat(hypr): script to simulate the awesomewm workspaces behaviour

This commit is contained in:
Sergio Laín 2024-04-02 12:32:12 +02:00
parent 4aef47abda
commit d30768a3e5
No known key found for this signature in database
GPG key ID: 14C9B8080681777B
2 changed files with 63 additions and 30 deletions

View file

@ -80,40 +80,31 @@ bind = SUPER, C, exec, hyprctl dispatch centerwindow 1
# Workspaces # Workspaces
# Focusing other workspaces # Focusing other workspaces
bind = SUPER, 1, exec, hyprsome workspace 1 $workspace = ~/.config/hypr/scripts/awesome_workspaces
bind = SUPER, 2, exec, hyprsome workspace 2 bind = SUPER, 1, exec, $workspace 1 switch
bind = SUPER, 3, exec, hyprsome workspace 3 bind = SUPER, 2, exec, $workspace 2 switch
bind = SUPER, 4, exec, hyprsome workspace 4 bind = SUPER, 3, exec, $workspace 3 switch
bind = SUPER, 5, exec, hyprsome workspace 5 bind = SUPER, 4, exec, $workspace 4 switch
bind = SUPER, 6, exec, hyprsome workspace 6 bind = SUPER, 5, exec, $workspace 5 switch
bind = SUPER, 7, exec, hyprsome workspace 7 bind = SUPER, 6, exec, $workspace 6 switch
bind = SUPER, 8, exec, hyprsome workspace 8 bind = SUPER, 7, exec, $workspace 7 switch
bind = SUPER, 9, exec, hyprsome workspace 9 bind = SUPER, 8, exec, $workspace 8 switch
bind = SUPER, 0, exec, hyprsome workspace 10 bind = SUPER, 9, exec, $workspace 9 switch
bind = SUPER, 0, exec, $workspace 10 switch
# Moving windows to other workspaces # Moving windows to other workspaces
bind = SUPERSHIFT, 1, exec, hyprsome movefocus 1 bind = SUPERSHIFT, 1, exec, $workspace 1 move
bind = SUPERSHIFT, 2, exec, hyprsome movefocus 2 bind = SUPERSHIFT, 2, exec, $workspace 2 move
bind = SUPERSHIFT, 3, exec, hyprsome movefocus 3 bind = SUPERSHIFT, 3, exec, $workspace 3 move
bind = SUPERSHIFT, 4, exec, hyprsome movefocus 4 bind = SUPERSHIFT, 4, exec, $workspace 4 move
bind = SUPERSHIFT, 5, exec, hyprsome movefocus 5 bind = SUPERSHIFT, 5, exec, $workspace 5 move
bind = SUPERSHIFT, 6, exec, hyprsome movefocus 6 bind = SUPERSHIFT, 6, exec, $workspace 6 move
bind = SUPERSHIFT, 7, exec, hyprsome movefocus 7 bind = SUPERSHIFT, 7, exec, $workspace 7 move
bind = SUPERSHIFT, 8, exec, hyprsome movefocus 8 bind = SUPERSHIFT, 8, exec, $workspace 8 move
bind = SUPERSHIFT, 9, exec, hyprsome movefocus 9 bind = SUPERSHIFT, 9, exec, $workspace 9 move
bind = SUPERSHIFT, 0, exec, hyprsome movefocus 10 bind = SUPERSHIFT, 0, exec, $workspace 10 move
# Moving windows to other workspaces (silent) # Moving windows to other workspaces (silent)
bind = SUPERALT, 1, exec, hyprsome move 1
bind = SUPERALT, 2, exec, hyprsome move 2
bind = SUPERALT, 3, exec, hyprsome move 3
bind = SUPERALT, 4, exec, hyprsome move 4
bind = SUPERALT, 5, exec, hyprsome move 5
bind = SUPERALT, 6, exec, hyprsome move 6
bind = SUPERALT, 7, exec, hyprsome move 7
bind = SUPERALT, 8, exec, hyprsome move 8
bind = SUPERALT, 9, exec, hyprsome move 9
bind = SUPERALT, 0, exec, hyprsome move 10
# Moving to other wokspace with mouse control # Moving to other wokspace with mouse control
bind = SUPER, mouse_down, workspace,m-1 bind = SUPER, mouse_down, workspace,m-1
@ -125,6 +116,16 @@ bind = SUPERCTRL, RIGHT, workspace,m+1
bind = SUPERCTRL, H, workspace,m-1 bind = SUPERCTRL, H, workspace,m-1
bind = SUPERCTRL, L, workspace,m+1 bind = SUPERCTRL, L, workspace,m+1
bind = SUPERALT, 1, exec, $workspace 1 silent
bind = SUPERALT, 2, exec, $workspace 2 silent
bind = SUPERALT, 3, exec, $workspace 3 silent
bind = SUPERALT, 4, exec, $workspace 4 silent
bind = SUPERALT, 5, exec, $workspace 5 silent
bind = SUPERALT, 6, exec, $workspace 6 silent
bind = SUPERALT, 7, exec, $workspace 7 silent
bind = SUPERALT, 8, exec, $workspace 8 silent
bind = SUPERALT, 9, exec, $workspace 9 silent
bind = SUPERALT, 0, exec, $workspace 10 silent
# Group control # Group control
bind = SUPER, G, togglegroup bind = SUPER, G, togglegroup

View file

@ -0,0 +1,32 @@
#!/usr/bin/bash
monitors=($(hyprctl monitors -j | jq -r '.[].id'))
ws_per_monitor=10
monitor=$(hyprctl activeworkspace -j | jq -r '.monitorID')
calculate_index() {
local index=$(($1 + $2 * ws_per_monitor))
echo $index
}
move_workspace() {
local index=$1
local action=$2
if [[ $action == "move" ]]; then
hyprctl dispatch movetoworkspace $index
elif [[ $action == "silent" ]]; then
hyprctl dispatch movetoworkspacesilent $index
else
hyprctl dispatch workspace $index
fi
}
for ((i = 0; i < ${#monitors[@]}; i++)); do
if [[ $monitor == "${monitors[i]}" ]]; then
index=$(calculate_index $1 $i)
move_workspace $index $2
break
fi
done