blob: 54f8a0fffa71e9f6eca6716d3111ccb10ad96fba (
plain)
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
|
#include <jo_lowbat.hpp>
#include <iostream>
#include <cstring>
#include <cstdint>
#include <thread>
#include <chrono>
using namespace this_thread;
using namespace chrono;
int main(int argc, const char *argv[]) {
Lowbat lowbat;
uint8_t speaks;
speaks = 0;
if (lowbat.jo_testAcpi()) {
return 1;
}
if (lowbat.jo_testNotifySend()) {
return 2;
}
if (argc > 2 && !strcmp(argv[1], "--say")) {
if (!lowbat.jo_testEspeak()) {
lowbat.jo_setMsg(argv[2]);
speaks = 1;
}
}
while (true) {
while (lowbat.jo_fetchBatlvl() < 15 && !lowbat.jo_fetchAcstat()) {
if (lowbat.jo_notify()) {
cerr << "Error: could not use notify-send" << endl;
return 3;
}
if (speaks && lowbat.jo_speak()) {
cerr << "Error: could not use espeak" << endl;
}
cout << "Sleep for 20s" << endl;
sleep_for(seconds(20));
}
cout << "Sleep for 4m" << endl;
sleep_for(seconds(240));
}
return 0;
}
|