mirror of
https://github.com/VectorKappa/dotfiles.git
synced 2025-12-19 08:16:10 +01:00
added binfiles from chrysostomus/bspwm-scripts, fixed eaten space
This commit is contained in:
31
bin/smartsplit
Executable file
31
bin/smartsplit
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
# Window splitting script for bspwm. Requires wmutils and xdotool. Splits window in its biggest dimension
|
||||
# in the direction that is closer to the cursor. Inspired by MouseLaunch and pseudo_automatic_rule.
|
||||
# Get the necessary info
|
||||
|
||||
eval $(xdotool getmouselocation --shell)
|
||||
IFS=" " read -a window <<< $(wattr whxy $(bspc query -N -n focused))
|
||||
|
||||
# Distance to each side
|
||||
north=$(( $Y - ${window[3]}))
|
||||
south=$(( ${window[3]} + ${window[1]} - $Y ))
|
||||
west=$(( $X - ${window[2]}))
|
||||
east=$(( ${window[2]} + ${window[0]} - $X ))
|
||||
# Dimensions of window
|
||||
widht=${window[0]}
|
||||
height=${window[1]}
|
||||
|
||||
# Determine which window edge in biggest dimension is closer
|
||||
if [[ "$widht" -lt "$height" ]] && [[ "$north" -lt "$south" ]]; then
|
||||
dir_final=north
|
||||
elif [[ "$widht" -lt "$height" ]] && [[ "$north" -ge "$south" ]]; then
|
||||
dir_final=south
|
||||
elif [[ "$widht" -ge "$height" ]] && [[ "$east" -ge "$west" ]]; then
|
||||
dir_final=west
|
||||
else
|
||||
dir_final=east
|
||||
fi
|
||||
|
||||
# Split the window accordingly
|
||||
bspc node -p \~$dir_final
|
||||
#echo "north=$north east=$east south=$south west=$west widht=$widht Height=$height $dir_final"
|
||||
Reference in New Issue
Block a user