-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbspc-smartmove
executable file
·137 lines (131 loc) · 4.08 KB
/
bspc-smartmove
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
# Set window to floating mode, then snap it to top right corner
resolution=($(getRes))
monitor_width=${resolution[0]}
monitor_height=${resolution[1]}
isFocusedWindowFloating() {
bspc query -N -n focused.floating > /dev/null
if [ $? -eq 0 ]; then
echo true
else
echo false
fi
}
case "$1" in
up)
if ($(isFocusedWindowFloating)); then
bspc node -v 0 -20
else
bspc node -s north
fi
;;
down)
if ($(isFocusedWindowFloating)); then
bspc node -v 0 20
else
bspc node -s south
fi
;;
left)
if ($(isFocusedWindowFloating)); then
bspc node -v -20 0
else
bspc node -s west
fi
;;
right)
if ($(isFocusedWindowFloating)); then
bspc node -v 20 0
else
bspc node -s east
fi
;;
# These should only be used by floating windows
top-left)
if ($(isFocusedWindowFloating)); then
window_xpos=$(returnWindowInfo.sh x)
window_ypos=$(returnWindowInfo.sh y)
bspc node -v "-$window_xpos" "-$window_ypos"
fi
;;
top-right)
if ($(isFocusedWindowFloating)); then
window_width=$(returnWindowInfo.sh w)
window_xpos=$(returnWindowInfo.sh x)
window_ypos=$(returnWindowInfo.sh y)
bspc node -v "$(( monitor_width - window_width - window_xpos ))" "-$window_ypos"
fi
;;
bottom-left)
if ($(isFocusedWindowFloating)); then
window_height=$(returnWindowInfo.sh h)
window_xpos=$(returnWindowInfo.sh x)
window_ypos=$(returnWindowInfo.sh y)
bspc node -v "-$window_xpos" "$(( monitor_height - window_height - window_ypos ))"
fi
;;
bottom-right)
if ($(isFocusedWindowFloating)); then
window_width=$(returnWindowInfo.sh w)
window_height=$(returnWindowInfo.sh h)
window_xpos=$(returnWindowInfo.sh x)
window_ypos=$(returnWindowInfo.sh y)
bspc node -v "$(( monitor_width - window_width - window_xpos ))" "$(( monitor_height - window_height - window_ypos ))"
fi
;;
top-center)
if ($(isFocusedWindowFloating)); then
window_width=$(returnWindowInfo.sh w)
window_xpos=$(returnWindowInfo.sh x)
window_ypos=$(returnWindowInfo.sh y)
offset_center_x="$(( monitor_width / 2 - window_width / 2 ))"
diff_x="$(( offset_center_x - window_xpos ))"
bspc node -v "$diff_x" "-$window_ypos"
fi
;;
bottom-center)
if ($(isFocusedWindowFloating)); then
window_width=$(returnWindowInfo.sh w)
window_height=$(returnWindowInfo.sh h)
window_xpos=$(returnWindowInfo.sh x)
window_ypos=$(returnWindowInfo.sh y)
offset_center_x="$(( monitor_width / 2 - window_width / 2 ))"
diff_x="$(( offset_center_x - window_xpos ))"
bspc node -v "$diff_x" "$(( monitor_height - window_height - window_ypos ))"
fi
;;
center-left)
if ($(isFocusedWindowFloating)); then
window_height=$(returnWindowInfo.sh h)
window_xpos=$(returnWindowInfo.sh x)
window_ypos=$(returnWindowInfo.sh y)
offset_center_y="$(( monitor_height / 2 - window_height / 2 ))"
diff_y="$(( offset_center_y - window_ypos ))"
bspc node -v "-$window_xpos" "$diff_y"
fi
;;
center)
if ($(isFocusedWindowFloating)); then
window_width=$(returnWindowInfo.sh w)
window_height=$(returnWindowInfo.sh h)
window_xpos=$(returnWindowInfo.sh x)
window_ypos=$(returnWindowInfo.sh y)
offset_center_x="$(( monitor_width / 2 - window_width / 2 ))"
diff_x="$(( offset_center_x - window_xpos ))"
offset_center_y="$(( monitor_height / 2 - window_height / 2 ))"
diff_y="$(( offset_center_y - window_ypos ))"
bspc node -v "$diff_x" "$diff_y"
fi
;;
center-right)
if ($(isFocusedWindowFloating)); then
window_width=$(returnWindowInfo.sh w)
window_height=$(returnWindowInfo.sh h)
window_xpos=$(returnWindowInfo.sh x)
window_ypos=$(returnWindowInfo.sh y)
offset_center_y="$(( monitor_height / 2 - window_height / 2 ))"
diff_y="$(( offset_center_y - window_ypos ))"
bspc node -v "$(( monitor_width - window_width - window_xpos ))" "$diff_y"
fi
;;
esac