Last active
November 3, 2022 10:29
-
-
Save drasill/d3f8def77643742678a9a5a235cd71fa to your computer and use it in GitHub Desktop.
bspwm : External Rules & Config for right-stacked windows
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 | |
# ~/.config/bspwm/bspwmrc | |
#... | |
bspc config external_rules_command ~/.config/bspwm/scripts/external_rules.sh |
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 | |
# ~/.config/bspwm/scripts/external_rules.sh | |
# If a preselection exists, use it | |
has_presel=$(bspc query --nodes --node '.!automatic') | |
if [ ! -z $has_presel ]; then | |
exit 0 | |
fi | |
# Check if root node is horizontal (sorry you need "jq" for this) | |
firstSplit=$(bspc query -T -d -n '@/' | jq -r '.splitType') | |
if [ $firstSplit = 'horizontal' ]; then | |
# Horizontal mode, create the main window on the left | |
echo "node=@/" | |
echo "split_dir=west" | |
echo "split_ratio=0.7" | |
exit 0 | |
fi | |
# Otherwise, it depends on the number of existing (non-float) windows | |
num=$(bspc query -N -n '.leaf.!floating' -d | wc -l) | |
if [ $num -eq 0 ]; then | |
# No window, just put it here | |
exit 0 | |
elif [ $num -eq 1 ]; then | |
# One window, split east | |
echo "split_dir=east" | |
echo "split_ratio=0.7" | |
else | |
# More than one window, split south | |
echo "node=@/2" | |
echo "split_dir=south" | |
echo "split_ratio=0.5" | |
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
# ~/.config/sxhkd/sxhkdrc | |
# Useful commands to work with the right-stacked windows | |
# balance windows | |
super + b | |
bspc node @parent -B | |
# zoom (swap to biggest window) | |
super + z | |
bspc node -s biggest.local |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment