Skip to content

Commit 618d7fa

Browse files
committed
stow: add amethyst custom layouts
1 parent a10e2fe commit 618d7fa

File tree

4 files changed

+223
-39
lines changed

4 files changed

+223
-39
lines changed

scripts/config.sh

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ stow_dotfiles() {
1919
".gitconfig"
2020
".jq"
2121
".profile*"
22+
".psqlrc"
2223
".vimrc"
2324
".zshrc"
2425
".zshenv"
2526
".zprofile"
2627
)
27-
local folders=(
28+
local directories=(
2829
".config/fd"
2930
".config/git"
3031
".config/nvim"
@@ -35,22 +36,32 @@ stow_dotfiles() {
3536
".gnupg"
3637
".ssh"
3738
)
39+
3840
info "Removing existing config files"
3941
for f in "${files[@]}"; do
4042
rm -f "$HOME/$f" || true
4143
done
4244

43-
# Create the folders to avoid symlinking folders
44-
for d in "${folders[@]}"; do
45+
info "Removing existing config directories"
46+
for d in "${directories[@]}"; do
4547
rm -rf "${HOME:?}/$d" || true
48+
# Create the folders to avoid symlinking folders
4649
mkdir -p "$HOME/$d"
4750
done
4851

4952
# shellcheck disable=SC2155
50-
local to_stow="$(find stow -maxdepth 1 -type d -mindepth 1 | awk -F "/" '{print $NF}' ORS=' ')"
53+
local to_stow="$(find stow -maxdepth 1 -type d -mindepth 1 -not -path "library" | awk -F "/" '{print $NF}' ORS=' ')"
5154
info "Stowing: $to_stow"
52-
stow -d stow --verbose 1 --target "$HOME" "$to_stow"
5355

54-
# set permissions
55-
chmod a+x ~/.git-templates/hooks/pre-commit
56+
read -p "Are you sure? " -n 1 -r
57+
if [[ ! $REPLY =~ ^[Yy]$ ]]
58+
then
59+
stow -d stow --verbose 1 --target "$HOME" "$to_stow"
60+
# set permissions
61+
chmod a+x ~/.git-templates/hooks/pre-commit
62+
63+
if [[ "$OSTYPE" == "darwin"* ]]; then
64+
stow -d stow --verbose 1 --target "$HOME/Library/Application Support/" library
65+
fi
66+
fi
5667
}

stow/amethyst/.config/amethyst/amethyst.yml

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ layouts:
44
- two-pane
55
- tall
66
# - 3column-middle
7+
- four-corners
8+
- center-focus
79
# - tall-right
810
# - wide
911
# - middle-wide
10-
# - 3column-left
12+
- 3column-left
1113
# - 3column-right
1214
# - 4column-left
1315
# - 4column-right
@@ -16,21 +18,18 @@ layouts:
1618
# - floating
1719
# - widescreen-tall
1820
# - widescreen-tall-right
19-
- bsp
21+
# - bsp
2022

2123
# First mod (default option + shift).
2224
mod1:
2325
- option
24-
# - shift
2526
- control
26-
# - command
2727

2828
# Second mod (default option + shift + control).
2929
mod2:
3030
- option
3131
- shift
3232
- control
33-
# - command
3433

3534
# Commands:
3635
# special key values
@@ -75,23 +74,6 @@ decrease-main:
7574
mod: mod1
7675
key: "."
7776

78-
# General purpose command for custom layouts. Functionality is layout-dependent.
79-
# command1:
80-
# mod: <NONE>
81-
# key: <NONE>
82-
# General purpose command for custom layouts. Functionality is layout-dependent.
83-
# command2:
84-
# mod: <NONE>
85-
# key: <NONE>
86-
# General purpose command for custom layouts. Functionality is layout-dependent.
87-
# command3:
88-
# mod: <NONE>
89-
# key: <NONE>
90-
# General purpose command for custom layouts. Functionality is layout-dependent.
91-
# command4:
92-
# mod: <NONE>
93-
# key: <NONE>
94-
9577
# Focus the next window in the list going counter-clockwise.
9678
focus-ccw:
9779
mod: mod1
@@ -159,22 +141,26 @@ swap-main:
159141

160142
# Select tall layout
161143
select-tall-layout:
162-
mod: mod1
163-
key: a
144+
mod: mod2
145+
key: q
164146

165147
select-two-pane-layout:
166148
mod: mod2
167-
key: d
149+
key: w
150+
151+
select-four-corners-layout:
152+
mod: mod2
153+
key: r
168154

169155
# Select fullscreen layout
170156
select-fullscreen-layout:
171-
mod: mod1
172-
key: d
157+
mod: mod2
158+
key: e
173159

174160
# Select column layout
175-
select-column-layout:
176-
mod: mod1
177-
key: f
161+
# select-column-layout:
162+
# mod: mod1
163+
# key: f
178164

179165
# Move the currently focused window to the space to the left.
180166
throw-space-left:
@@ -189,7 +175,7 @@ throw-space-right:
189175
# Toggle the floating state of the currently focused window; i.e., if it was floating make it tiled and if it was tiled make it floating.
190176
toggle-float:
191177
mod: mod1
192-
key: t
178+
key: f
193179

194180
# Display the layout HUD with the current layout on each screen.
195181
display-current-layout:
@@ -305,4 +291,4 @@ screen-padding-bottom: 10
305291
restore-layouts-on-launch: true
306292

307293
# true to display some optional debug information in the layout HUD (default false).
308-
debug-layout-info: false
294+
debug-layout-info: true
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
function layout() {
2+
return {
3+
name: "Center Focus",
4+
getFrameAssignments: (windows, screenFrame) => {
5+
// If the screen is large enough, use a grid layout with a focus in the center
6+
const gridWidth = screenFrame.width / 4;
7+
const centerWidth = gridWidth * 2;
8+
const gutterWidth = gridWidth;
9+
const leftGutterOffsetX = screenFrame.x;
10+
const centerOffsetX = gridWidth;
11+
const rightGutterOffsetX = gridWidth + centerWidth;
12+
const cornerHeight = screenFrame.height / 2;
13+
const fullCornerHeight = screenFrame.height / 2;
14+
15+
const centerFrame = {
16+
x: centerOffsetX,
17+
y: screenFrame.y,
18+
width: centerWidth,
19+
height: screenFrame.height,
20+
};
21+
22+
const topLeftGutterFrame = {
23+
x: leftGutterOffsetX,
24+
y: screenFrame.y,
25+
width: gutterWidth,
26+
height: cornerHeight,
27+
};
28+
29+
const topRightGutterFrame = {
30+
x: rightGutterOffsetX,
31+
y: screenFrame.y,
32+
width: gutterWidth,
33+
height: cornerHeight,
34+
};
35+
36+
const bottomLeftGutterFrame = {
37+
x: leftGutterOffsetX,
38+
y: screenFrame.y + cornerHeight,
39+
width: gutterWidth,
40+
height: cornerHeight,
41+
};
42+
43+
const bottomRightGutterFrame = {
44+
x: rightGutterOffsetX,
45+
y: screenFrame.y + cornerHeight,
46+
width: gutterWidth,
47+
height: cornerHeight,
48+
};
49+
50+
let remainderHeight = 0;
51+
52+
if (windows.length > 5) {
53+
remainderHeight = fullCornerHeight / (windows.length - 4);
54+
}
55+
56+
const frames = windows.map((window, index) => {
57+
if (windows.length == 1) {
58+
// If there is only one window, it should take up the full screen
59+
const frame = centerFrame;
60+
return { [window.id]: frame };
61+
} else {
62+
// If there are two windows, they should each take up half of the screen
63+
if (index == 0) {
64+
const frame = centerFrame;
65+
return { [window.id]: frame };
66+
} else if (index == 1) {
67+
const frame = topLeftGutterFrame;
68+
return { [window.id]: frame };
69+
} else if (index == 2) {
70+
const frame = topRightGutterFrame;
71+
return { [window.id]: frame };
72+
} else if (index == 3) {
73+
const frame = bottomLeftGutterFrame;
74+
return { [window.id]: frame };
75+
} else if (index == 4 && windows.length == 5) {
76+
const frame = bottomRightGutterFrame;
77+
return { [window.id]: frame };
78+
} else {
79+
const frame = {
80+
x: rightGutterOffsetX,
81+
y: screenFrame.y + cornerHeight + remainderHeight * (index - 4),
82+
width: gutterWidth,
83+
height: remainderHeight,
84+
};
85+
return { [window.id]: frame };
86+
}
87+
}
88+
});
89+
return frames.reduce((frames, frame) => ({ ...frames, ...frame }), {});
90+
},
91+
};
92+
}
93+
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
function layout() {
2+
return {
3+
name: "Four Corners",
4+
getFrameAssignments: (windows, screenFrame) => {
5+
const fullCornerHeight = screenFrame.height / 2;
6+
const fullCornerWidth = screenFrame.width / 2;
7+
8+
let remainderHeight = 0;
9+
const remainderWidth = fullCornerWidth;
10+
11+
if (windows.length > 4) {
12+
remainderHeight = fullCornerHeight / (windows.length - 3);
13+
}
14+
15+
const frames = windows.map((window, index) => {
16+
if (windows.length == 1) {
17+
// If there is only one window, it should take up the full screen
18+
const frame = {
19+
x: screenFrame.x,
20+
y: screenFrame.y,
21+
width: screenFrame.width,
22+
height: screenFrame.height
23+
};
24+
return { [window.id]: frame };
25+
} else if (windows.length == 2) {
26+
// If there are two windows, they should each take up half of the screen
27+
if (index == 0) {
28+
const frame = {
29+
x: screenFrame.x,
30+
y: screenFrame.y,
31+
width: fullCornerWidth,
32+
height: screenFrame.height
33+
};
34+
return { [window.id]: frame };
35+
} else {
36+
const frame = {
37+
x: screenFrame.x + fullCornerWidth,
38+
y: screenFrame.y,
39+
width: fullCornerWidth,
40+
height: screenFrame.height
41+
};
42+
return { [window.id]: frame };
43+
}
44+
} else if (windows.length == 3) {
45+
// If there are three windows, the first window should take up the left half of the screen, and the other two should take up the right half
46+
if (index == 0) {
47+
const frame = {
48+
x: screenFrame.x,
49+
y: screenFrame.y,
50+
width: fullCornerWidth,
51+
height: screenFrame.height
52+
};
53+
return { [window.id]: frame };
54+
} else if (index == 1) {
55+
const frame = {
56+
x: screenFrame.x + fullCornerWidth,
57+
y: screenFrame.y,
58+
width: fullCornerWidth,
59+
height: fullCornerHeight
60+
};
61+
return { [window.id]: frame };
62+
} else {
63+
const frame = {
64+
x: screenFrame.x + fullCornerWidth,
65+
y: screenFrame.y + fullCornerHeight,
66+
width: fullCornerWidth,
67+
height: fullCornerHeight
68+
};
69+
return { [window.id]: frame };
70+
}
71+
} else if (index <= 2 || index == 3 && windows.length == 4) {
72+
// If there are four windows, they should each take up a quarter of the screen
73+
const frame = {
74+
x: screenFrame.x + (fullCornerWidth * (index % 2)),
75+
y: screenFrame.y + (fullCornerHeight * Math.floor(index / 2)),
76+
width: fullCornerWidth,
77+
height: fullCornerHeight
78+
};
79+
return { [window.id]: frame };
80+
} else {
81+
// If there are more than four windows, the first three should take up the top left, top right, bottom left of the screen, and the rest should take up the bottom right of the screen
82+
const frame = {
83+
x: screenFrame.x + fullCornerWidth,
84+
y: screenFrame.y + fullCornerHeight + (remainderHeight * (index - 3)),
85+
width: remainderWidth,
86+
height: remainderHeight
87+
}
88+
return { [window.id]: frame };
89+
}
90+
});
91+
return frames.reduce((frames, frame) => ({ ...frames, ...frame }), {});
92+
}
93+
};
94+
}

0 commit comments

Comments
 (0)