diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/jo_notify.cpp | 8 | ||||
-rw-r--r-- | src/main.cpp | 14 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/jo_notify.cpp b/src/jo_notify.cpp index 1683871..bd14db0 100644 --- a/src/jo_notify.cpp +++ b/src/jo_notify.cpp @@ -1,6 +1,6 @@ #include <jo_lowbat.hpp> -void +int jo_notify(const string batlvl) { string str = nullptr; const char *cmd = nullptr; @@ -10,10 +10,10 @@ jo_notify(const string batlvl) { str += "%\" \"Please plug in computer\" -u critical -t 15000"; cmd = str.c_str(); - system(cmd); + return system(cmd); } -void +int jo_speak(const string msg) { string str = nullptr; const char *cmd = nullptr; @@ -22,5 +22,5 @@ jo_speak(const string msg) { str += msg; str += "\" | espeak"; cmd = str.c_str(); - system(cmd); + return system(cmd); } diff --git a/src/main.cpp b/src/main.cpp index 2fe6063..ed05f71 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,19 +4,19 @@ int main(int argc, const char *argv[]) { string msg = nullptr; string acstat = nullptr; string batlvl = nullptr; - stringstream battoint = nullptr; int batlvlint = 0; - if (memcmp(argv[1], "--say", strlen(argv[1]))) - msg = "beep beep - low battery"; - else - msg = argv[2]; + if (argc > 1) { + if (memcmp(argv[1], "--say", strlen(argv[1]))) + msg = "beep beep - low battery"; + else + msg = argv[2]; + } while (true) { acstat = jo_exec("acpi | awk '{print $3}' | rev | cut -c 2- | rev"); batlvl = jo_exec("acpi | awk '{print $4}' | rev | cut -c 3- | rev"); - battoint = batlvl; - battoint >> batlvlint; + batlvlint = stoi(batlvl); if (batlvlint < 15) { while (!memcmp(acstat, "Discharging", strlen(acstat))) { jo_notify(batlvl); |