diff --git a/dot_config/hypr/hyprland.d/20-workspaces.conf.tmpl b/dot_config/hypr/hyprland.d/20-workspaces.conf.tmpl index cf907a0..d42faf7 100644 --- a/dot_config/hypr/hyprland.d/20-workspaces.conf.tmpl +++ b/dot_config/hypr/hyprland.d/20-workspaces.conf.tmpl @@ -1,3 +1,15 @@ +## ========== Special Workspaces ========== +workspace = special:passwordmgr, on-created-empty:uwsm app -- bitwarden-desktop + +## ========== Named Workspaces (IDs 1-6, sorted before numbered) ========== +workspace = 1, defaultName:comms, monitor:DP-2, layout:scrolling, layoutopt:direction:down, persistent:true +workspace = 2, defaultName:element, monitor:DP-2, layout:scrolling, layoutopt:direction:down, persistent:true +workspace = 3, defaultName:mail, persistent:true +workspace = 4, defaultName:joplin, persistent:true +workspace = 5, defaultName:steam, layout:scrolling, persistent:true +workspace = 6, defaultName:spotify, monitor:DP-2, layout:monocle, persistent:true, on-created-empty:uwsm app -- spotify-launcher + +## ========== Monitor Workspaces ========== {{- range $monitor := .monitors }} {{- range $index, $ws := $monitor.workspaces }} {{- if kindIs "map" $ws }} diff --git a/dot_config/hypr/hyprland.d/60-rules.conf b/dot_config/hypr/hyprland.d/60-rules.conf index ffe4d48..4a70f40 100644 --- a/dot_config/hypr/hyprland.d/60-rules.conf +++ b/dot_config/hypr/hyprland.d/60-rules.conf @@ -73,17 +73,6 @@ windowrule = match:class .*, suppress_event maximize windowrule = match:class ^$, match:title ^$, match:xwayland 1, match:float 1, match:fullscreen 0, match:pin 0, no_focus on windowrule = match:xwayland 1, no_initial_focus on -## ========== Special Workspaces ========== -workspace = special:passwordmgr, on-created-empty:uwsm app -- bitwarden-desktop - -## ========== Named Workspaces (IDs 1-5, sort before numbered) ========== -workspace = 1, defaultName:comms, monitor:DP-2, layout:scrolling, layoutopt:direction:down, persistent:true -workspace = 2, defaultName:element, monitor:DP-2, layout:scrolling, layoutopt:direction:down, persistent:true -workspace = 3, defaultName:mail, persistent:true -workspace = 4, defaultName:joplin, persistent:true -workspace = 5, defaultName:steam, layout:scrolling, persistent:true -workspace = 6, defaultName:spotify, monitor:DP-2, layout:monocle, persistent:true, on-created-empty:uwsm app -- spotify-launcher - #windowrule = float, class:org.keepassxc.KeePassXC #windowrule = noscreenshare, class:org.keepassxc.KeePassXC #windowrule = size 60% 60%, class:org.keepassxc.KeePassXC diff --git a/dot_config/hypr/hyprland.d/70-keybinds.conf.tmpl b/dot_config/hypr/hyprland.d/70-keybinds.conf.tmpl index 90d8457..233296c 100644 --- a/dot_config/hypr/hyprland.d/70-keybinds.conf.tmpl +++ b/dot_config/hypr/hyprland.d/70-keybinds.conf.tmpl @@ -112,16 +112,14 @@ bind = $mainMod, L, movefocus, r bind = $mainMod, K, movefocus, u bind = $mainMod, J, movefocus, d -# MOVE WINDOW with mainMod SHIFT + vim keys -bind = $mainMod SHIFT, H, movewindow, l -bind = $mainMod SHIFT, L, movewindow, r -bind = $mainMod SHIFT, K, movewindow, u -bind = $mainMod SHIFT, J, movewindow, d +# MOVE WINDOW with mainMod SHIFT + vim keys (layout-aware) +bind = $mainMod SHIFT, H, exec, hypr-workspace-layout move-left +bind = $mainMod SHIFT, L, exec, hypr-workspace-layout move-right +bind = $mainMod SHIFT, K, exec, hypr-workspace-layout move-up +bind = $mainMod SHIFT, J, exec, hypr-workspace-layout move-down -bind = $mainMod ALT SHIFT, H, layoutmsg, swapcol l -bind = $mainMod ALT SHIFT, J, layoutmsg, colresize -0.1 -bind = $mainMod ALT SHIFT, K, layoutmsg, colresize +0.1 -bind = $mainMod ALT SHIFT, L, layoutmsg, swapcol r +bind = $mainMod ALT SHIFT, J, exec, hypr-workspace-layout resize-shrink-h +bind = $mainMod ALT SHIFT, K, exec, hypr-workspace-layout resize-grow-h # Resize submap bind = $mainMod, R, submap, resize diff --git a/dot_local/bin/executable_hypr-workspace-layout b/dot_local/bin/executable_hypr-workspace-layout index d25947f..67ec1f3 100644 --- a/dot_local/bin/executable_hypr-workspace-layout +++ b/dot_local/bin/executable_hypr-workspace-layout @@ -2,8 +2,8 @@ set -euo pipefail mode="${1:-}" -if [[ "$mode" != "toggle-ms" && "$mode" != "cycle" && "$mode" != "nav-next" && "$mode" != "nav-prev" && "$mode" != "nav-up" && "$mode" != "nav-down" ]]; then - printf 'Usage: %s {toggle-ms|cycle|nav-next|nav-prev|nav-up|nav-down}\n' "${0##*/}" >&2 +if [[ "$mode" != "toggle-ms" && "$mode" != "cycle" && "$mode" != "nav-next" && "$mode" != "nav-prev" && "$mode" != "nav-up" && "$mode" != "nav-down" && "$mode" != "move-left" && "$mode" != "move-right" && "$mode" != "move-up" && "$mode" != "move-down" && "$mode" != "resize-grow-h" && "$mode" != "resize-shrink-h" ]]; then + printf 'Usage: %s {toggle-ms|cycle|nav-next|nav-prev|nav-up|nav-down|move-left|move-right|move-up|move-down|resize-grow-h|resize-shrink-h}\n' "${0##*/}" >&2 exit 2 fi @@ -65,14 +65,14 @@ set_state() { mv "$tmp" "$state_file" } -default_layout="master" -if [[ "$ws_selector" == "name:comms" || "$ws_selector" == "name:steam" ]]; then - default_layout="scrolling" -fi - current_layout="$(get_state "$ws_key")" if [[ -z "$current_layout" ]]; then - current_layout="$default_layout" + if command -v jq >/dev/null 2>&1; then + current_layout="$(printf '%s' "$active_json" | jq -r '.tiledLayout // empty')" + else + current_layout="$(printf '%s' "$active_json" | sed -n 's/.*"tiledLayout":"\([^"]*\)".*/\1/p')" + fi + current_layout="${current_layout:-master}" fi if [[ "$mode" == "toggle-ms" ]]; then @@ -123,6 +123,40 @@ elif [[ "$mode" == "nav-up" ]]; then hyprctl dispatch cyclenext prev >/dev/null fi exit 0 +elif [[ "$mode" == "move-left" ]]; then + if [[ "$current_layout" == "scrolling" ]]; then + hyprctl dispatch layoutmsg "swapcol l" >/dev/null + elif [[ "$current_layout" != "monocle" ]]; then + hyprctl dispatch movewindow l >/dev/null + fi + exit 0 +elif [[ "$mode" == "move-right" ]]; then + if [[ "$current_layout" == "scrolling" ]]; then + hyprctl dispatch layoutmsg "swapcol r" >/dev/null + elif [[ "$current_layout" != "monocle" ]]; then + hyprctl dispatch movewindow r >/dev/null + fi + exit 0 +elif [[ "$mode" == "move-up" ]]; then + [[ "$current_layout" != "monocle" ]] && hyprctl dispatch movewindow u >/dev/null + exit 0 +elif [[ "$mode" == "move-down" ]]; then + [[ "$current_layout" != "monocle" ]] && hyprctl dispatch movewindow d >/dev/null + exit 0 +elif [[ "$mode" == "resize-grow-h" ]]; then + if [[ "$current_layout" == "scrolling" ]]; then + hyprctl dispatch layoutmsg "colresize +0.1" >/dev/null + elif [[ "$current_layout" != "monocle" ]]; then + hyprctl dispatch resizeactive 25 0 >/dev/null + fi + exit 0 +elif [[ "$mode" == "resize-shrink-h" ]]; then + if [[ "$current_layout" == "scrolling" ]]; then + hyprctl dispatch layoutmsg "colresize -0.1" >/dev/null + elif [[ "$current_layout" != "monocle" ]]; then + hyprctl dispatch resizeactive -25 0 >/dev/null + fi + exit 0 fi hyprctl keyword workspace "$ws_selector,layout:$next_layout" >/dev/null