-
-
Notifications
You must be signed in to change notification settings - Fork 131
/
index.jsx
191 lines (176 loc) · 6.97 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import * as Uebersicht from "uebersicht";
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 AerospaceContextProvider from "./lib/components/aerospace-context.jsx";
import UserWidgets from "./lib/components/data/user-widgets.jsx";
import * as YabaiSpaces from "./lib/components/yabai/spaces.jsx";
import * as YabaiProcess from "./lib/components/yabai/process.jsx";
import * as AerospaceSpaces from "./lib/components/aerospace/spaces.jsx";
import * as AerospaceProcess from "./lib/components/aerospace/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 YouTubeMusic from "./lib/components/data/youtube-music.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 { React } = Uebersicht;
const refreshFrequency = false;
const settings = Settings.get();
const {
// Do not edit the yabaiPath or aerospacePath lines, theses values are simply
// a default value used if nothing is defined in settings.
// You can setup your custom yabai or AeroSpace path in the settings module :
// while on an empty workspace, click on simple-bar then press cmd + , to open it.
yabaiPath = "/usr/local/bin/yabai",
aerospacePath = "/opt/homebrew/bin/aerospace",
windowManager,
shell,
enableServer,
yabaiServerRefresh,
} = settings.global;
const { hideWindowTitle, displayOnlyIcon, displaySkhdMode } = settings.process;
const disableSignals = enableServer && yabaiServerRefresh;
const enableTitleChangedSignal = !hideWindowTitle && !displayOnlyIcon;
const yabaiArgs = `${yabaiPath} ${displaySkhdMode} ${disableSignals} ${enableTitleChangedSignal}`;
const aerospaceArgs = `${aerospacePath}`;
const args = windowManager === "yabai" ? yabaiArgs : aerospaceArgs;
const command = `${shell} simple-bar/lib/scripts/init-${windowManager}.sh ${args}`;
Utils.injectStyles("simple-bar-index-styles", [
Variables.styles,
Base.styles,
YabaiSpaces.styles,
YabaiProcess.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,
YouTubeMusic.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 index.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} />;
}
if (Utils.cleanupOutput(output) === "aerospaceError") {
return <Error.Component type="aerospaceError" 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 />
{windowManager === "yabai" ? (
<YabaiContextProvider
spaces={spaces}
windows={windows}
skhdMode={skhdMode}
>
<YabaiSpaces.Component />
<YabaiProcess.Component />
</YabaiContextProvider>
) : (
<AerospaceContextProvider>
<AerospaceSpaces.Component />
<AerospaceProcess.Component />
</AerospaceContextProvider>
)}
<Settings.Wrapper />
<div className="simple-bar__data">
<UserWidgets />
<Zoom.Widget />
<BrowserTrack.Widget />
<Spotify.Widget />
<YouTubeMusic.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 };