aboutsummaryrefslogtreecommitdiff
path: root/.scripts/bspwm_resize.sh
blob: 29ab5cf7157ec9fe06475d4db35e3b9a50638271 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash

size=${2:-'10'}
dir=$1

# Find current window mode
is_tiled() {
bspc query -T -n | grep -q '"state":"tiled"'
}
# If the window is floating, move it
if ! is_tiled; then
#only parse input if window is floating,tiled windows accept input as is
        case "$dir" in
                west) switch="-w"
                sign="-"
                ;;
                east) switch="-w"
                sign="+"
                ;;
                north) switch="-h"
                sign="-"
                ;;
                south) switch="-h"
                sign="+"
                ;;
                esac
 xdo resize ${switch} ${sign}${size}

# Otherwise, window is tiled: switch with window in given direction
else
     case "$dir" in
                west) bspc node @west -r -$size || bspc node @east -r -${size}
                ;;
                east) bspc node @west -r +$size || bspc node @east -r +${size}
                ;;
                north) bspc node @south -r -$size || bspc node @north -r -${size}
                ;;
                south) bspc node @south -r +$size || bspc node @north -r +${size}
                ;;
                esac
fi

##!/bin/bash
#
#[ "$#" -eq 3 ] || { echo "Needs exactly three arguments."; exit 1; }
#
#motion="$1"
#direction="$2"
#size="$3"
#
#if [ "$motion" = 'expand' ]; then
#	# These expand the window's given side
#	case "$direction" in
#		north) bspc node -z top 0 -"$size" ;;
#		east) bspc node -z right "$size" 0 ;;
#		south) bspc node -z bottom 0 "$size" ;;
#		west) bspc node -z left -"$size" 0 ;;
#	esac
#else
#	# These contract the window's given side
#	case "$direction" in
#		north) bspc node -z top 0 "$size" ;;
#		east) bspc node -z right -"$size" 0 ;;
#		south) bspc node -z bottom 0 -"$size" ;;
#		west) bspc node -z left "$size" 0 ;;
#	esac
#fi