Skip to content

Commit 725bfb7

Browse files
authored
Merge pull request #9 from phenax/feature/reverse
Reversed layouts
2 parents 2e19c7d + b91bad8 commit 725bfb7

File tree

4 files changed

+137
-3
lines changed

4 files changed

+137
-3
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ _______________
3535
|________|____|
3636
```
3737

38+
* `rtall` - Master-stack with a reversed tall window.
39+
```
40+
_______________
41+
|____| |
42+
|____| |
43+
|____| |
44+
|____|________|
45+
```
46+
3847
* `wide` - Master-stack with a wide window.
3948
```
4049
_______________
@@ -44,6 +53,15 @@ _______________
4453
|____|____|___|
4554
```
4655

56+
* `rwide` - Master-stack with a reversed wide window.
57+
```
58+
_______________
59+
|____|____|___|
60+
| |
61+
| |
62+
|_____________|
63+
```
64+
4765
* `even` - Evenly balances all window areas
4866
```
4967
_______________

src/layout.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ Commands:
2121
help - See this help menu
2222
2323
Layout options:
24-
Tall
25-
--master-size 0.6 Set the master window size
26-
Wide
24+
tall,wide,rtall,rwide
2725
--master-size 0.6 Set the master window size
2826
";
2927

src/layouts/rtall.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
3+
source "$ROOT/utils/common.sh";
4+
source "$ROOT/utils/layout.sh";
5+
source "$ROOT/utils/config.sh";
6+
7+
master_size=$TALL_RATIO;
8+
9+
node_filter="!hidden";
10+
11+
execute_layout() {
12+
while [[ ! "$#" == 0 ]]; do
13+
case "$1" in
14+
--master-size) master_size="$2"; shift; ;;
15+
*) echo "$x" ;;
16+
esac;
17+
shift;
18+
done;
19+
20+
# ensure the count of the master child is 1, or make it so
21+
local nodes=$(bspc query -N '@/2' -n .descendant_of.window.$node_filter);
22+
local win_count=$(echo "$nodes" | wc -l);
23+
24+
if [ $win_count -ne 1 ]; then
25+
local new_node=$(bspc query -N '@/2' -n last.descendant_of.window.$node_filter | head -n 1);
26+
27+
if [ -z "$new_node" ]; then
28+
new_node=$(bspc query -N '@/1' -n last.descendant_of.window.$node_filter | head -n 1);
29+
fi
30+
31+
local root=$(echo "$nodes" | head -n 1);
32+
33+
# move everything into 2 that is not our new_node
34+
for wid in $(bspc query -N '@/2' -n .descendant_of.window.$node_filter | grep -v $root); do
35+
bspc node "$wid" -n '@/1';
36+
done
37+
38+
bspc node "$root" -n '@/2';
39+
fi
40+
41+
rotate '@/' vertical 90;
42+
rotate '@/2' horizontal 90;
43+
44+
local stack_node=$(bspc query -N '@/1' -n);
45+
for parent in $(bspc query -N '@/1' -n .descendant_of.!window.$node_filter | grep -v $stack_node); do
46+
rotate $parent horizontal 90;
47+
done
48+
49+
auto_balance '@/1';
50+
51+
local mon_width=$(jget width "$(bspc query -T -m)");
52+
53+
local want=$(echo "$master_size * $mon_width" | bc | sed 's/\..*//');
54+
local have=$(jget width "$(bspc query -T -n '@/2')");
55+
56+
bspc node '@/2' --resize left $((have - want)) 0;
57+
}
58+
59+
execute_layout "$@";

src/layouts/rwide.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
3+
source "$ROOT/utils/common.sh";
4+
source "$ROOT/utils/layout.sh";
5+
source "$ROOT/utils/config.sh";
6+
7+
master_size=$WIDE_RATIO;
8+
9+
node_filter="!hidden";
10+
11+
execute_layout() {
12+
while [[ ! "$#" == 0 ]]; do
13+
case "$1" in
14+
--master-size) master_size="$2"; shift; ;;
15+
*) echo "$x" ;;
16+
esac;
17+
shift;
18+
done;
19+
20+
# ensure the count of the master child is 1, or make it so
21+
local nodes=$(bspc query -N '@/2' -n .descendant_of.window.$node_filter);
22+
local win_count=$(echo "$nodes" | wc -l);
23+
24+
if [ $win_count -ne 1 ]; then
25+
local new_node=$(bspc query -N '@/2' -n last.descendant_of.window.$node_filter | head -n 1);
26+
27+
if [ -z "$new_node" ]; then
28+
new_node=$(bspc query -N '@/1' -n last.descendant_of.window.$node_filter | head -n 1);
29+
fi
30+
31+
local root=$(echo "$nodes" | head -n 1);
32+
33+
# move everything into 2 that is not our new_node
34+
for wid in $(bspc query -N '@/2' -n .descendant_of.window.$node_filter | grep -v $root); do
35+
bspc node "$wid" -n '@/1';
36+
done
37+
38+
bspc node "$root" -n '@/2';
39+
fi
40+
41+
rotate '@/' horizontal 90;
42+
rotate '@/2' vertical 90;
43+
44+
local stack_node=$(bspc query -N '@/1' -n);
45+
for parent in $(bspc query -N '@/1' -n .descendant_of.!window.$node_filter | grep -v $stack_node); do
46+
rotate $parent vertical 90;
47+
done
48+
49+
auto_balance '@/1';
50+
51+
local mon_height=$(jget height "$(bspc query -T -m)");
52+
53+
local want=$(echo "$master_size * $mon_height" | bc | sed 's/\..*//');
54+
local have=$(jget height "$(bspc query -T -n '@/2')");
55+
56+
bspc node '@/2' --resize top 0 $((have - want));
57+
}
58+
59+
execute_layout "$@";

0 commit comments

Comments
 (0)