vitorpy's Dotfiles
at main 22 lines 766 B view raw
1#!/usr/bin/env bash 2# ~/.config/hypr/send_to_next_free_ws.sh 3HYPRCTL=/usr/bin/hyprctl 4JQ=/usr/bin/jq 5 6mon_id="$($HYPRCTL monitors -j | $JQ -r '.[] | select(.focused==true) | .id')" 7 8# next empty ws on this monitor 9empty_ws="$($HYPRCTL workspaces -j | $JQ -r \ 10 --argjson mid "$mon_id" '.[] | select(.monitorID==$mid and .windows==0) | .id' | sort -n | head -n1)" 11 12if [ -z "$empty_ws" ]; then 13 # make a new one after the highest existing on this monitor 14 last="$($HYPRCTL workspaces -j | $JQ -r \ 15 --argjson mid "$mon_id" '.[] | select(.monitorID==$mid) | .id' | sort -n | tail -n1)" 16 empty_ws=$(( ${last:-0} + 1 )) 17fi 18 19# Move focused window silently, then follow it 20$HYPRCTL dispatch movetoworkspacesilent "$empty_ws" 21$HYPRCTL dispatch workspace "$empty_ws" 22