-
-
Notifications
You must be signed in to change notification settings - Fork 129
/
index.jsx
164 lines (150 loc) · 5.66 KB
/
index.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import * as Error from "./lib/components/error.jsx";
import SimpleBarContextProvider from "./lib/components/simple-bar-context.jsx";
import YabaiContextProvider from "./lib/components/yabai-context.jsx";
import UserWidgets from "./lib/components/data/user-widgets.jsx";
import * as Spaces from "./lib/components/spaces/spaces.jsx";
import * as Process from "./lib/components/spaces/process.jsx";
import * as Variables from "./lib/styles/core/variables";
import * as Base from "./lib/styles/core/base";
import * as Zoom from "./lib/components/data/zoom.jsx";
import * as Time from "./lib/components/data/time.jsx";
import * as DateDisplay from "./lib/components/data/date-display.jsx";
import * as Weather from "./lib/components/data/weather.jsx";
import * as Netstats from "./lib/components/data/netstats.jsx";
import * as Cpu from "./lib/components/data/cpu.jsx";
import * as Battery from "./lib/components/data/battery.jsx";
import * as Sound from "./lib/components/data/sound.jsx";
import * as Mic from "./lib/components/data/mic.jsx";
import * as Wifi from "./lib/components/data/wifi.jsx";
import * as ViscosityVPN from "./lib/components/data/viscosity-vpn.jsx";
import * as Keyboard from "./lib/components/data/keyboard.jsx";
import * as Spotify from "./lib/components/data/spotify.jsx";
import * as Crypto from "./lib/components/data/crypto.jsx";
import * as Stock from "./lib/components/data/stock.jsx";
import * as Music from "./lib/components/data/music.jsx";
import * as Mpd from "./lib/components/data/mpd.jsx";
import * as BrowserTrack from "./lib/components/data/browser-track.jsx";
import * as Specter from "./lib/components/data/specter.jsx";
import * as Graph from "./lib/components/data/graph.jsx";
import * as DataWidgetLoader from "./lib/components/data/data-widget-loader.jsx";
import * as DataWidget from "./lib/components/data/data-widget.jsx";
import * as SideIcon from "./lib/components/side-icon.jsx";
import * as Utils from "./lib/utils";
import * as Settings from "./lib/settings";
const refreshFrequency = false;
const settings = Settings.get();
const {
yabaiPath = "/usr/local/bin/yabai",
shell,
enableServer,
yabaiServerRefresh,
} = settings.global;
const { hideWindowTitle, displayOnlyIcon, displaySkhdMode } = settings.process;
const disableSignals = enableServer && yabaiServerRefresh;
const enableTitleChangedSignal = !hideWindowTitle && !displayOnlyIcon;
const args = `${yabaiPath} ${displaySkhdMode} ${disableSignals} ${enableTitleChangedSignal}`;
const command = `${shell} simple-bar/lib/scripts/init.sh ${args}`;
Utils.injectStyles("simple-bar-index-styles", [
Variables.styles,
Base.styles,
Spaces.styles,
Process.styles,
Settings.styles,
DataWidget.styles,
DateDisplay.styles,
Zoom.styles,
Time.styles,
Weather.styles,
Netstats.styles,
Cpu.styles,
Crypto.styles,
Stock.styles,
Battery.styles,
Wifi.styles,
ViscosityVPN.styles,
Keyboard.styles,
Mic.styles,
Sound.styles,
Spotify.styles,
Music.styles,
Mpd.styles,
BrowserTrack.styles,
Specter.styles,
Graph.styles,
DataWidgetLoader.styles,
settings.customStyles.styles,
SideIcon.styles,
]);
function render({ output, error }) {
const baseClasses = Utils.classNames("simple-bar", {
"simple-bar--floating": settings.global.floatingBar,
"simple-bar--no-bar-background": settings.global.noBarBg,
"simple-bar--no-color-in-data": settings.global.noColorInData,
"simple-bar--on-bottom": settings.global.bottomBar,
"simple-bar--inline-spaces-options": settings.global.inlineSpacesOptions,
"simple-bar--spaces-background-color-as-foreground":
settings.global.spacesBackgroundColorAsForeground,
"simple-bar--widgets-background-color-as-foreground":
settings.global.widgetsBackgroundColorAsForeground,
"simple-bar--process-aligned-to-left": !settings.global.centered,
});
if (error) {
// eslint-disable-next-line no-console
console.error("Error in spaces.jsx", error);
return <Error.Component type="error" classes={baseClasses} />;
}
if (!output) return <Error.Component type="noOutput" classes={baseClasses} />;
if (Utils.cleanupOutput(output) === "yabaiError") {
return <Error.Component type="yabaiError" classes={baseClasses} />;
}
const data = Utils.parseJson(output);
if (!data) return <Error.Component type="noData" classes={baseClasses} />;
const { displays, shadow, skhdMode, SIP, spaces, windows } = data;
const SIPDisabled = SIP !== "System Integrity Protection status: enabled.";
const classes = Utils.classNames(baseClasses, {
"simple-bar--no-shadow": shadow !== "on",
});
Utils.handleBarFocus();
return (
<SimpleBarContextProvider
initialSettings={settings}
displays={displays}
SIPDisabled={SIPDisabled}
>
<div className={classes}>
<SideIcon.Component />
<YabaiContextProvider
spaces={spaces}
windows={windows}
skhdMode={skhdMode}
>
<Spaces.Component />
<Process.Component />
</YabaiContextProvider>
<Settings.Wrapper />
<div className="simple-bar__data">
<UserWidgets />
<Zoom.Widget />
<BrowserTrack.Widget />
<Spotify.Widget />
<Crypto.Widget />
<Stock.Widget />
<Music.Widget />
<Mpd.Widget />
<Weather.Widget />
<Netstats.Widget />
<Cpu.Widget />
<Battery.Widget />
<Mic.Widget />
<Sound.Widget />
<ViscosityVPN.Widget />
<Wifi.Widget />
<Keyboard.Widget />
<DateDisplay.Widget />
<Time.Widget />
</div>
</div>
</SimpleBarContextProvider>
);
}
export { command, refreshFrequency, render };