aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-06 22:41:33 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-06 22:41:33 +0200
commit5f1fdd425ad147efd33b54b39deb1d50459185c2 (patch)
tree408ca975011c6e7d62826891189d3a69da870d7f /src/main.cpp
parentCanceled system() remplacement for libnotify as it leaks a lot (diff)
downloadlowbat-gnu-5f1fdd425ad147efd33b54b39deb1d50459185c2.tar.gz
lowbat-gnu-5f1fdd425ad147efd33b54b39deb1d50459185c2.tar.bz2
lowbat-gnu-5f1fdd425ad147efd33b54b39deb1d50459185c2.tar.xz
lowbat-gnu-5f1fdd425ad147efd33b54b39deb1d50459185c2.tar.zst
lowbat-gnu-5f1fdd425ad147efd33b54b39deb1d50459185c2.zip
ACPI is not required anymore
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 54f8a0f..2452840 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -13,15 +13,11 @@ int main(int argc, const char *argv[]) {
uint8_t speaks;
speaks = 0;
- if (lowbat.jo_testAcpi()) {
- return 1;
- }
if (lowbat.jo_testNotifySend()) {
- return 2;
+ return (JO_RET_MISS_DEP);
}
if (argc > 2 && !strcmp(argv[1], "--say")) {
if (!lowbat.jo_testEspeak()) {
- lowbat.jo_setMsg(argv[2]);
speaks = 1;
}
}
@@ -29,9 +25,12 @@ int main(int argc, const char *argv[]) {
while (lowbat.jo_fetchBatlvl() < 15 && !lowbat.jo_fetchAcstat()) {
if (lowbat.jo_notify()) {
cerr << "Error: could not use notify-send" << endl;
- return 3;
+ return (JO_RET_NOTIFY_FAILED);
}
- if (speaks && lowbat.jo_speak()) {
+ if (speaks) {
+ lowbat.jo_setMsg(argv[2]);
+ lowbat.jo_speak();
+ lowbat.jo_delMsg();
cerr << "Error: could not use espeak" << endl;
}
cout << "Sleep for 20s" << endl;
@@ -40,5 +39,5 @@ int main(int argc, const char *argv[]) {
cout << "Sleep for 4m" << endl;
sleep_for(seconds(240));
}
- return 0;
+ return (JO_RET_FINE);
}