#!/bin/sh

set -eu

selection="$({
    printf '1\tDwindle — binary split\n'
    printf '2\tMaster — main window plus stack\n'
    printf '3\tScrolling — columns\n'
    printf '4\tMonocle — one window at a time\n'
} | noctalia dmenu -p 'Layout for current workspace (1-4)')" || exit 0

case "$selection" in
    1*) layout=dwindle ;;
    2*) layout=master ;;
    3*) layout=scrolling ;;
    4*) layout=monocle ;;
    *) exit 0 ;;
esac

workspace="$(hyprctl activeworkspace -j | jq -r '.id')"

case "$workspace" in
    ''|*[!0-9]*) exit 1 ;;
esac

# Workspace rules are scoped to this workspace; changing general:layout would
# affect every workspace.
hyprctl keyword workspace "$workspace, layout:$layout"
