Skip to content

Instantly share code, notes, and snippets.

@ortango
Created February 16, 2021 00:21
Show Gist options
  • Save ortango/29f8f4f4d6465c522e82ac60e64bb35d to your computer and use it in GitHub Desktop.
Save ortango/29f8f4f4d6465c522e82ac60e64bb35d to your computer and use it in GitHub Desktop.
move node like "bubble"
#!/bin/bash
[[ "$1" == '-r' ]] && rotate=yes && shift
[[ -n "$1" ]] || exit 1
declare -A \
toggledir=([north]=south [south]=north [east]=west [west]=east) \
splitdir=([north]=horizontal [south]=horizontal [east]=vertical [west]=vertical)
dest=$(bspc query -N -n "${1}.window.local")
if bro="$(bspc query -N -n @brother)" && [[ "$rotate" ]]; then
bspc query -N -n "@parent.${splitdir[$1]}" &>/dev/null ||
dest="$bro"
fi
[[ -n "$dest" ]] || exit
[[ "$dest" != "$bro" ]] &&
set -- ${toggledir[$1]}
bspc node "$dest" -p "$1" &&
bspc node -n "$dest"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment