summaryrefslogtreecommitdiff
path: root/dotfiles/hyprland/.local/bin/stash-restore
blob: ddaa5a450190721054d4e2fc813db67e42251aaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
# Restore all windows from special:stash to current workspace
# Preserves current master window position using batch commands

workspace=$(hyprctl activeworkspace -j | jq -r '.id')
original_focus=$(hyprctl activewindow -j | jq -r '.address')

# Get all windows in special:stash
stashed=$(hyprctl clients -j | jq -r '.[] | select(.workspace.name == "special:stash") | .address')

if [ -z "$stashed" ]; then
    exit 0
fi

# Restore each window, then swap original back to master (batched for atomicity)
for addr in $stashed; do
    hyprctl --batch "dispatch movetoworkspacesilent $workspace,address:$addr ; dispatch focuswindow address:$original_focus ; dispatch layoutmsg swapwithmaster master"
done