Skip to content

Instantly share code, notes, and snippets.

@lukepighetti
Created February 17, 2023 02:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lukepighetti/f00dd91d4da3e8ac83944b8a44ce16f0 to your computer and use it in GitHub Desktop.
Save lukepighetti/f00dd91d4da3e8ac83944b8a44ce16f0 to your computer and use it in GitHub Desktop.
My Amethyst Ultrawide Layout
const centerColumnWidthFactor = 0.4;
// Prioritizes center with adjustable width factor
// Fills column left, then right
// Then splits right column vertically
// Then splits left column vertically
function layout() {
return {
name: "Ultrawide Simple",
getFrameAssignments: (windows, screenFrame) => {
const rowHeight = screenFrame.height / 2;
const centerColumnWidth = screenFrame.width * centerColumnWidthFactor;
const sideColumnWidth = (screenFrame.width - centerColumnWidth) / 2;
const frames = windows.map((window, index) => {
let frame;
const definitions = {
1: {
0: { x: 1, y: 0, h: 2 },
},
2: {
0: { x: 1, y: 0, h: 2 },
1: { x: 0, y: 0, h: 2 },
},
3: {
0: { x: 1, y: 0, h: 2 },
1: { x: 0, y: 0, h: 2 },
2: { x: 2, y: 0, h: 2 },
},
4: {
0: { x: 1, y: 0, h: 2 },
1: { x: 0, y: 0, h: 2 },
2: { x: 2, y: 0, h: 1 },
3: { x: 2, y: 1, h: 1 },
},
5: {
0: { x: 1, y: 0, h: 2 },
1: { x: 0, y: 0, h: 1 },
2: { x: 2, y: 0, h: 1 },
3: { x: 2, y: 1, h: 1 },
4: { x: 0, y: 1, h: 1 },
},
}
let d = definitions[windows.length][index];
let width = d.x == 1 ?
centerColumnWidth : sideColumnWidth;
let x = d.x == 0 ? 0 :
d.x == 1 ? sideColumnWidth :
sideColumnWidth + centerColumnWidth;
frame = {
x: screenFrame.x + x,
y: screenFrame.y + rowHeight * d.y,
width: width,
height: rowHeight * d.h,
};
return { [window.id]: frame };
});
return frames.reduce((frames, frame) => ({ ...frames, ...frame }), {});
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment