-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
spaces.jsx
50 lines (46 loc) · 1.25 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
import Desktop from "./lib/Desktop.jsx";
import Error from "./lib/Error.jsx";
import parse from "./lib/parse.jsx";
import styles from "./lib/styles.jsx";
const style = {
padding: "0 8px",
display: "grid",
gridAutoFlow: "column",
gridGap: "16px",
position: "fixed",
overflow: "hidden",
left: "0px",
top: "0px",
fontFamily: styles.fontFamily,
lineHeight: styles.lineHeight,
fontSize: styles.fontSize,
color: styles.colors.dim,
fontWeight: styles.fontWeight
};
export const refreshFrequency = false;
export const command = "./nibar/scripts/spaces.sh";
export const render = ({ output }, ...args) => {
const data = parse(output);
if (typeof data === "undefined") {
return (
<div style={style}>
<Error msg="Error: unknown script output" side="left" />
</div>
);
}
if (typeof data.error !== "undefined") {
return (
<div style={style}>
<Error msg={`Error: ${data.error}`} side="left" />
</div>
);
}
const displayId = Number(window.location.pathname.replace(/\D+/g, ''));
const display = data.displays.find(d => d.id === displayId);
return (
<div style={style}>
<Desktop output={data.spaces.filter(s => s.display === display.index)} />
</div>
);
};
export default null;