-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathspaces.jsx
81 lines (74 loc) · 2.52 KB
/
spaces.jsx
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
import Desktop from "./lib/Desktop.jsx";
import Error from "./lib/Error.jsx";
import parse from "./lib/parse.jsx";
import styles from "./lib/styles.jsx";
import settings from "./lib/settings.jsx";
import {applyBarHeight} from "./lib/autoBarHeight.jsx";
const baseStyle = {
display: "grid",
gridAutoFlow: "column",
gridGap: "16px",
position: "fixed",
overflow: "hidden",
padding: styles.padding + "px" + " " + (settings.bar.paddingHorizontal - settings.bar.space.paddingHorizontal + 3) + "px",
height: styles.heightWithoutPadding + "px",
lineHeight: styles.heightWithoutPadding + "px",
width: "auto",
...(settings.bar.alignBottom ? {bottom: "0px"} : {top: "0px"}),
left: "0px",
fontFamily: styles.fontFamily,
lineHeight: styles.lineHeight,
fontSize: styles.fontSize,
color: styles.colors.dim,
fontWeight: styles.fontWeight,
zIndex: 101,
};
export const refreshFrequency = false;
export const command = "./clarity/scripts/windows.sh";
export const render = ({ output }, ...args) => {
let style = {...baseStyle};
if (typeof output === "undefined" || !output) {
return (
<div style={style}>
<Desktop placeholder={"..."}/>
</div>
);
}
const data = output ? parse(output) : undefined;
const displayId = Number(window.location.pathname.split("/")[1]);
const displayData = data?.displays?.find(d => d.id === displayId);
const [dw, dh, duuid] = [displayData?.frame?.w || 0, displayData?.frame?.h || 0, displayData?.uuid];
style = applyBarHeight(dw, dh, duuid)(style, -settings.bar.paddingVertical*2);
if (typeof data === "undefined") {
return (
<div style={style}>
<Desktop placeholder={"invalid"}/>
</div>
);
}
if (typeof data.error !== "undefined") {
return (
<div style={style}>
<Desktop placeholder={"error"}/>
</div>
);
}
if (!data.spaces || !data.displays) {
return (
<div style={style}>
<Desktop placeholder={"unknown"}/>
</div>
);
}
const display = data.displays.find(d => d.id === displayId);
return (
<div style={style}>
<Desktop
displayData={display}
spaceData={data.spaces.filter(s => s.display === display.index)}
windowData={data.windows.filter(w => w.display === display.index)}
/>
</div>
);
};
export default null;