-
-
Save ortango/398e8404b031e2990597575f0560618f to your computer and use it in GitHub Desktop.
bspwm master/stack layout mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
masterlayout.sh& | |
bspc config external_rules_command external_rules.sh | |
bspc config click_to_focus button1 | |
bspc config pointer_modifier mod4 | |
bspc config pointer_action1 move | |
bspc config pointer_action3 resize_corner | |
bspc config border_width 4 | |
bspc config split_ratio 0.50 | |
bspc config removal_adjustment false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
bspc query -N -n .leaf.local.\!automatic >/dev/null && exit | |
master_area="${BSPWMMASTER:-west}" west="@/1" east="@/2" north="$west" south="$east" | |
case "$master_area" in | |
west|east) ss_dir="south";;& | |
west) stack_area="east";; | |
east) stack_area="west";; | |
north|south) ss_dir="east";;& | |
north) stack_area="south";; | |
south) stack_area="north";; | |
esac | |
localnodect="$(bspc query -N -n .leaf.local | wc -l)" | |
if [ $localnodect -gt 1 ]; then | |
echo "node=${!stack_area} split_dir=${ss_dir}" | |
else | |
echo "private=on split_dir=${stack_area}" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
was_master() { grep -x "$n" <<<"$lastmasters" >/dev/null; } | |
last_master_ct() { wc -l <<<"$lastmasters"; } | |
win_ct() { bspc query -N -d -n .window | wc -l; } | |
is_last_master_aleaf() { bspc query -N -n "${!master_area}.leaf" >/dev/null; } | |
root_split() { bspc query -T -n @/ | jq -r '.splitType'; } | |
master_area="${BSPWMMASTER:-west}" west="@/1" east="@/2" north="$west" south="$east" | |
case "$master_area" in | |
west|east) rs_dir="vertical";;& | |
west) stack_area="east";; | |
east) stack_area="west";; | |
north|south) rs_dir="horizontal";;& | |
north) stack_area="south";; | |
south) stack_area="north";; | |
esac | |
while read a m d n _; do | |
if [[ "$a" = "node_remove" || "$a" = "node_transfer" ]] && was_master; then | |
if [[ $(last_master_ct) -eq 1 && $(win_ct) -gt 1 ]] && ! is_last_master_aleaf; then | |
bspc node @/ -p "$master_area" | |
bspc node biggest.window.local -n @/ | |
fi | |
if [[ "$(root_split)" != "$rs_dir" ]]; then | |
bspc node "${!master_area}" -p "$stack_area" | |
bspc node "${!stack_area}" -n "${!master_area}" | |
fi | |
fi | |
bspc node "${!master_area}" -g private=on -B | |
bspc node "${!stack_area}" -g private=off -B | |
lastmasters="$(bspc query -N "${!master_area}" -n .descendant_of.local.window)" | |
done <"$(bspc subscribe -f node_add node_transfer node_remove node_swap)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment