-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
31 lines (29 loc) · 1.14 KB
/
main.ts
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
const si = require('systeminformation');
const http = require('http');
http.createServer( function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
si.battery( (data) => {
let { percent, timeremaining, ischarging } = data;
res.end(`<!DOCTYPE html>
<html lang="en">
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
<link href="https://fonts.googleapis.com/css?family=Major+Mono+Display&display=swap" rel="stylesheet"/>
<title>Battery</title>
<style>
body {
font-family: 'Major Mono Display', monospace;
font-size: 7vw;
color: lightgray;
background: black;
text-align: center;
}
</style>
</head>
<body>
<h1>${percent}%</h1>
<h1>${ischarging? 'charging': timeremaining + ' min.'}</h1>
</body>
</html>`);
});
}).listen(Number(process.argv[2]));