forked from kkga/nibar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
music.jsx
55 lines (46 loc) · 1.34 KB
/
music.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
import parse from "./lib/parse.jsx"
import Spotify from "./lib/Spotify.jsx"
import styles from "./lib/styles.jsx";
const style = {
display: "grid",
padding: "0 12px",
gridAutoFlow: "column",
gridGap: "20px",
position: "fixed",
overflow: "hidden",
right: "calc(50% - 100px)",
top: "0px",
color: styles.colors.dim,
fontFamily: styles.fontFamily,
fontSize: styles.fontSize,
lineHeight: styles.lineHeight,
fontWeight: styles.fontWeight,
}
export const command = './ayu-nibar/scripts/music.sh'
export const refreshFrequency = false
export const initialState = { output: { spotify: { status: "", artist: "", name: "" } } }
export const updateState = (event, previousState) => {
if (event.error) {
return {...previousState, error: `Received error: ${event.error}`}
}
const data = parse(event.output)
if (typeof data === "undefined") {
return {...previousState, error: "Failed to parse output of command"}
}
return { output: data }
}
export const render = ({ output, error }) => {
if (error) {
console.log(error)
}
const data = output["spotify"]
const totalLength = Object.values(data).join('').length
if (totalLength === 0) {
return null
}
return (
<div style={style}>
<Spotify output={data}/>
</div>
)
}