forked from Jean-Tinland/simple-bar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spaces.jsx
53 lines (40 loc) · 1.71 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
import Spaces from './lib/components/Spaces.jsx'
import Error from './lib/components/Error.jsx'
import { parseJson, getTheme } from './lib/utils.js'
import { getSettings } from './lib/settings.js'
import { styles } from './lib/styles/Styles.js'
import CustomStyles from './lib/styles/CustomStyles.js'
const refreshFrequency = false
const settings = getSettings()
const theme = getTheme(settings)
const Styles = styles[theme]
const className = `
${Styles.BaseStyles}
${Styles.SpacesStyles}
${settings.global.floatingBar ? Styles.FloatingBarOverride : ''}
${settings.global.noBarBg ? Styles.NoBarBgOverride : ''}
${settings.global.bottomBar ? Styles.BottomBarOverride : ''}
${settings.global.floatingBar && settings.global.bottomBar ? Styles.FloatinBottomBarOverride : ''}
${settings.global.inlineSpacesOptions ? Styles.InlineSpacesOptionsOverride : ''}
${CustomStyles}
`
const { yabaiPath, shell } = settings.global
const command = `${shell} simple-bar/lib/scripts/get_spaces.sh ${yabaiPath}`
const render = ({ output, error }) => {
if (error) {
console.log('Error in spaces.jsx', error)
return <Error widget="spaces" type="error" />
}
if (error) return <Error widget="spaces" type="error" />
if (!output) return <Error widget="spaces" type="noOutput" />
const data = parseJson(output)
if (!data) return <Error widget="spaces" type="noData" />
const displayId = parseInt(window.location.pathname.replace('/', ''))
const displayIndex = data.displays.find((d) => d.id === displayId).index
return (
<div className="simple-bar simple-bar--spaces">
<Spaces output={data.spaces} SIP={data.SIP} displayIndex={displayIndex} />
</div>
)
}
export { command, refreshFrequency, className, render }