-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.jsx
100 lines (87 loc) · 2.29 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
import { run } from "uebersicht";
import {
container,
basicBox,
separator,
weatherIcon,
weatherContainer
} from "./lib/styles";
export const refreshFrequency = 5000;
export const command = async (dispatch) => {
const [
app,
battery,
cpu,
memory,
net,
space,
time,
volume,
weather
] = await Promise.all([
run("bash ubersicht-osbar/scripts/app.sh"),
run("bash ubersicht-osbar/scripts/battery.sh"),
run("bash ubersicht-osbar/scripts/cpu.sh"),
run("bash ubersicht-osbar/scripts/memory.sh"),
run("bash ubersicht-osbar/scripts/net.sh"),
run("bash ubersicht-osbar/scripts/space.sh"),
run("bash ubersicht-osbar/scripts/time.sh"),
run("bash ubersicht-osbar/scripts/volume.sh"),
run("bash ubersicht-osbar/scripts/weather.sh"),
]);
dispatch({
type: "UPDATE",
data: {app, battery, cpu, memory, net, space, time, volume, weather},
});
};
export const initialState = {};
export const updateState = (action, state) => {
switch (action.type) {
case "UPDATE":
return action.data;
default:
return state;
}
};
export const render = (data) => (
<div className={container}>
<div className={basicBox.neon}>
{data.space}
</div>
{ data.app ?
<div className={basicBox.simple}>
{data.app}
</div>
:
''
}
<div className={separator}></div>
<div className={basicBox.simple}>
{data.net}
</div>
<div className={basicBox.cpu}>
<span>{parseInt(data.cpu)}</span>
</div>
<div className={basicBox.mem}>
<span>{parseInt(data.memory)}</span>
</div>
<div className={basicBox.juice}>
<span>{data.battery}</span>
</div>
<div className={basicBox.weather}>
{(data.weather !== undefined && JSON.parse(data.weather).length > 0 && !isNaN(parseFloat(JSON.parse(data.weather)[0]))) ?
<div className={weatherContainer}>
<img className={weatherIcon} src={'http://openweathermap.org/img/w/' + JSON.parse(data.weather)[1] + '.png'} />
{Math.trunc(parseFloat(JSON.parse(data.weather)[0]))}°
</div>
:
<div className={weatherContainer}>
<span>...</span>
</div>
}
</div>
<div className={basicBox.dark}>
{data.time}
</div>
</div>
);