Skip to content

Instantly share code, notes, and snippets.

@yannbertrand
Created November 6, 2025 09:23
Show Gist options
  • Save yannbertrand/961a2164aabdf36fd84c81cc62ba4ece to your computer and use it in GitHub Desktop.
Save yannbertrand/961a2164aabdf36fd84c81cc62ba4ece to your computer and use it in GitHub Desktop.
aerospace pip-move
#!/bin/bash
focused_workspace=$(aerospace list-workspaces --focused)
nb_of_monitors=$(aerospace list-monitors | wc | awk '{print $1}')
focused_monitor=$(aerospace list-monitors --focused | awk '{print $1}')
pip_windows=$(aerospace list-windows --all --format " %{window-id}%{right-padding} | %{monitor-id}%{right-padding} | %{window-title}" | grep -E "(Picture-in-Picture|Picture in Picture)")
echo $pip_windows | while read window; do
window_id=$(echo $window | awk '{print $1}')
monitor_id=$(echo $window | awk '{print $3}')
if [ -n "$window_id" ]; then
if [ "$nb_of_monitors" -gt 1 ]; then
# If multiple monitors, only move on wanted one
if [ "$monitor_id" -eq "$focused_monitor" ]; then
aerospace move-node-to-workspace --window-id "$window_id" "$focused_workspace"
fi
else
# Move PiP windows to current workspace (handles both "Picture-in-Picture" and "Picture in Picture")
aerospace move-node-to-workspace --window-id "$window_id" "$focused_workspace"
fi
fi
done
@yannbertrand
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment