diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2019-12-04 01:15:22 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2019-12-04 01:15:22 +0100 |
commit | 13386e8a1035fb84bf9d579e49ebe595b14e803d (patch) | |
tree | 60b59474dee116e66fa3ebb539828cb9c9c1cc58 /src/main.cpp | |
parent | Better includes, better Makefile (diff) | |
download | lowbat-gnu-13386e8a1035fb84bf9d579e49ebe595b14e803d.tar.gz lowbat-gnu-13386e8a1035fb84bf9d579e49ebe595b14e803d.tar.bz2 lowbat-gnu-13386e8a1035fb84bf9d579e49ebe595b14e803d.tar.xz lowbat-gnu-13386e8a1035fb84bf9d579e49ebe595b14e803d.tar.zst lowbat-gnu-13386e8a1035fb84bf9d579e49ebe595b14e803d.zip |
Useless if removed
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/main.cpp b/src/main.cpp index 71f7147..69d4ef5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,13 +8,25 @@ using namespace this_thread; using namespace chrono; int main(int argc, const char *argv[]) { - string msg; - string acstat; - string batlvl; - int batlvlint; + string msg; + string acstat; + string batlvl; + string arg_one; + string arg_two; + int batlvlint; - if (argc > 1 && !memcmp(argv[1], "--say", strlen(argv[1]))) - msg = argv[2]; + if (argc > 1) { + arg_one = argv[1]; + if (argc > 2) + { + arg_two = argv[2]; + if (!memcmp(arg_one.c_str(), "--say", strlen("--say"))) + msg = arg_two; + } + } + else { + msg = "Beep beep - low battery"; + } while (true) { acstat = jo_exec("acpi | awk '{print $3}' | rev | cut -c 2- | rev"); @@ -23,17 +35,15 @@ int main(int argc, const char *argv[]) { batlvl.erase(remove(batlvl.begin(), batlvl.end(), '\n'), batlvl.end()); batlvlint = stoi(batlvl); if (batlvlint < 90) { - while (!memcmp(acstat.c_str(), "Discharging", strlen(acstat.c_str()))) { + while (!memcmp(acstat.c_str(), "Discharging", strlen("Discharging"))) { jo_notify(batlvl); - if (memcmp(argv[1], "--silent", strlen(argv[1]))) + if (memcmp(arg_one.c_str(), "--silent", strlen("--silent"))) jo_speak(msg); sleep_for(seconds(20)); acstat = jo_exec("acpi | awk '{print $3}' | rev | cut -c 2- | rev"); batlvl = jo_exec("acpi | awk '{print $4}' | rev | cut -c 3- | rev"); acstat.erase(remove(acstat.begin(), acstat.end(), '\n'), acstat.end()); batlvl.erase(remove(batlvl.begin(), batlvl.end(), '\n'), batlvl.end()); - if (!memcmp(acstat.c_str(), "Charging", strlen(acstat.c_str()))) - break ; } } sleep_for(seconds(240)); |