clicksnap update

master
Daniel Napora 2021-05-07 12:42:30 +02:00
parent 0e1190f96b
commit 09cd079155
1 changed files with 14 additions and 11 deletions

View File

@ -7,12 +7,14 @@
### Configuration ### Configuration
# Gap between windows # Gap between windows
GAP="32" GAP="32"
show_outer_gap="true"
# TITLEBAR HEIGHT - no idea how to find it from cli # TITLEBAR HEIGHT - no idea how to find it from cli
TITLEBAR_HEIGHT="20" TITLEBAR_HEIGHT="20"
# Activate moved windows? # Activate moved windows?
activate_window="false" activate_window="false"
### End Configuration ### End Configuration
eval $(xdotool getmouselocation --shell) eval $(xdotool getmouselocation --shell)
Mouse_x="$X" Mouse_x="$X"
Mouse_y="$Y" Mouse_y="$Y"
@ -20,15 +22,17 @@ Mouse_y="$Y"
HEX_ID=$(printf '0x%x\n' $WINDOW) HEX_ID=$(printf '0x%x\n' $WINDOW)
CHILD_ID=$(xwininfo -id $HEX_ID -children|grep "\"" | awk '{print $1}') CHILD_ID=$(xwininfo -id $HEX_ID -children|grep "\"" | awk '{print $1}')
if xwininfo -id $CHILD_ID -wm |grep Dock ; then exit 0 ;fi # Ignore Dock eg. tint2 if xwininfo -id $CHILD_ID -wm |grep Dock ; then exit 0 ;fi # Ignore Dock eg. tint2
if xwininfo -id $CHILD_ID -wm |grep Undecorated ; then # Undecorated if xwininfo -id $CHILD_ID -wm |grep Undecorated ; then # Undecorated
T="0" T="0"
else # Decorated else # Decorated
T="$TITLEBAR_HEIGHT" T="$TITLEBAR_HEIGHT"
fi fi
## OUTER GAP
if [[ "$show_outer_gap" == "true" ]]; then OUT_GAP="$GAP" ; else OUT_GAP="0" ; fi
echo "OUT_GAP: $OUT_GAP"
eval $(xdotool getwindowgeometry --shell $WINDOW) eval $(xdotool getwindowgeometry --shell $WINDOW)
Win_x="$X" Win_x="$X"
Win_y="$Y" Win_y="$Y"
@ -53,26 +57,25 @@ OFF_Y="${OFFSET#*,}"
case $POS_CODE in case $POS_CODE in
00) # top-left 00) # top-left
W=$((AVAIL_X/2-GAP*3/2)) H=$((AVAIL_Y/2-T-GAP*3/2)) X=$((0+OFF_X+GAP)) Y=$((0+OFF_Y+GAP));; W=$((AVAIL_X/2-OUT_GAP-GAP/2)) H=$((AVAIL_Y/2-T-OUT_GAP-GAP/2)) X=$((0+OFF_X+OUT_GAP)) Y=$((0+OFF_Y+OUT_GAP));;
10) # top 10) # top
W=$((AVAIL_X-GAP*2)) H=$((AVAIL_Y/2-T-GAP*3/2)) X=$((0+OFF_X+GAP)) Y=$((0+OFF_Y+GAP));; W=$((AVAIL_X-OUT_GAP*2)) H=$((AVAIL_Y/2-T-OUT_GAP-GAP/2)) X=$((0+OFF_X+OUT_GAP)) Y=$((0+OFF_Y+OUT_GAP));;
20) # top-right 20) # top-right
W=$((AVAIL_X/2-GAP*3/2)) H=$((AVAIL_Y/2-T-GAP*3/2)) X=$((AVAIL_X/2+OFF_X+GAP/2)) Y=$((0+OFF_Y+GAP));; W=$((AVAIL_X/2-OUT_GAP-GAP/2)) H=$((AVAIL_Y/2-T-OUT_GAP-GAP/2)) X=$((AVAIL_X/2+OFF_X+GAP/2)) Y=$((0+OFF_Y+OUT_GAP));;
01) # left 01) # left
W=$((AVAIL_X/2-GAP*3/2)) H=$((AVAIL_Y-T-GAP*2)) X=$((0+OFF_X+GAP)) Y=$((0+OFF_Y+GAP));; W=$((AVAIL_X/2-OUT_GAP-GAP/2)) H=$((AVAIL_Y-T-OUT_GAP*2)) X=$((0+OFF_X+OUT_GAP)) Y=$((0+OFF_Y+OUT_GAP));;
11) # center 11) # center
W=$((AVAIL_X/8*6-OFF_X)) H=$((AVAIL_Y/8*6-T)) X=$((AVAIL_X/8+OFF_X/2)) Y=$((AVAIL_Y/8+OFF_Y/2));; W=$((AVAIL_X/8*6-OFF_X)) H=$((AVAIL_Y/8*6-T)) X=$((AVAIL_X/8+OFF_X/2)) Y=$((AVAIL_Y/8+OFF_Y/2));;
21) # right 21) # right
W=$((AVAIL_X/2-GAP*3/2)) H=$((AVAIL_Y-T-GAP*2)) X=$((AVAIL_X/2+OFF_X+GAP/2)) Y=$((0+OFF_Y+GAP));; W=$((AVAIL_X/2-OUT_GAP-GAP/2)) H=$((AVAIL_Y-T-OUT_GAP*2)) X=$((AVAIL_X/2+OFF_X+GAP/2)) Y=$((0+OFF_Y+OUT_GAP));;
02) # bottom-left 02) # bottom-left
W=$((AVAIL_X/2-GAP*3/2)) H=$((AVAIL_Y/2-T-GAP*3/2)) X=$((0+OFF_X+GAP)) Y=$((AVAIL_Y/2+OFF_Y+GAP/2));; W=$((AVAIL_X/2-OUT_GAP-GAP/2)) H=$((AVAIL_Y/2-T-OUT_GAP-GAP/2)) X=$((0+OFF_X+OUT_GAP)) Y=$((AVAIL_Y/2+OFF_Y+GAP/2));;
12) # bottom 12) # bottom
W=$((AVAIL_X-GAP*2)) H=$((AVAIL_Y/2-T-GAP*3/2)) X=$((0+OFF_X+GAP)) Y=$((AVAIL_Y/2+OFF_Y+GAP/2));; W=$((AVAIL_X-OUT_GAP*2)) H=$((AVAIL_Y/2-T-OUT_GAP-GAP/2)) X=$((0+OFF_X+OUT_GAP)) Y=$((AVAIL_Y/2+OFF_Y+GAP/2));;
22) # bottom-right 22) # bottom-right
W=$((AVAIL_X/2-GAP*3/2)) H=$((AVAIL_Y/2-T-GAP*3/2)) X=$((AVAIL_X/2+OFF_X+GAP/2)) Y=$((AVAIL_Y/2+OFF_Y+GAP/2));; W=$((AVAIL_X/2-OUT_GAP-GAP/2)) H=$((AVAIL_Y/2-T-OUT_GAP-GAP/2)) X=$((AVAIL_X/2+OFF_X+GAP/2)) Y=$((AVAIL_Y/2+OFF_Y+GAP/2));;
esac esac
xdotool windowsize $WINDOW $W $H xdotool windowsize $WINDOW $W $H
xdotool windowmove $WINDOW $X $Y xdotool windowmove $WINDOW $X $Y
if [ $activate_window == "true" ]; then xdotool windowactivate $WINDOW; fi if [ $activate_window == "true" ]; then xdotool windowactivate $WINDOW; fi