diff options
-rw-r--r-- | inc/jo_lowbat.hpp | 2 | ||||
-rw-r--r-- | src/jo_lowbat.cpp | 13 | ||||
-rw-r--r-- | src/main.cpp | 7 |
3 files changed, 14 insertions, 8 deletions
diff --git a/inc/jo_lowbat.hpp b/inc/jo_lowbat.hpp index a2bd06e..7428c86 100644 --- a/inc/jo_lowbat.hpp +++ b/inc/jo_lowbat.hpp @@ -10,7 +10,7 @@ class Lowbat { public: uint8_t jo_testAcpi(void); uint8_t jo_testNotifySend(void); - void jo_testEspeak(void); + uint8_t jo_testEspeak(void); int jo_fetchBatlvl(void); int jo_fetchAcstat(void); int jo_notify(void); diff --git a/src/jo_lowbat.cpp b/src/jo_lowbat.cpp index b6cc0d6..73a91b3 100644 --- a/src/jo_lowbat.cpp +++ b/src/jo_lowbat.cpp @@ -22,11 +22,11 @@ Lowbat::jo_testNotifySend(void) { cout << "notify-send is not installed. Please install it in order to run lowbat" << endl; return 1; } - cout << "notify-send is installed" + cout << "notify-send is installed" << endl; return 0; } -void +uint8_t Lowbat::jo_testEspeak(void) { if (system("which espeak > /dev/null 2>&1")) { cout << "espeak is not installed. Please install it in order to run --say option" << endl; @@ -47,11 +47,14 @@ Lowbat::jo_fetchBatlvl(void) { int Lowbat::jo_fetchAcstat(void) { - const int ret = system("acpi | grep -q Discharging"); + int ret; + + cout << "Fetching acstat: " + ret = system("acpi | grep -q Discharging"); if (ret != 0) - cout << ret << "acstat: Charging" << endl; + cout << "Charging" << endl; else - cout << "acstat: Discharging" << endl; + cout << "Discharging" << endl; return ret; } diff --git a/src/main.cpp b/src/main.cpp index 56ee872..d9f6874 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,6 @@ #include <jo_lowbat.hpp> #include <iostream> +#include <cstring> #include <cstdint> #include <thread> #include <chrono> @@ -12,10 +13,12 @@ int main(int argc, const char *argv[]) { uint8_t speaks; speaks = 0; - if (lowbat.jo_testAcpi()) + if (lowbat.jo_testAcpi()) { return 1; - if (lowbat.jo_testNotifySend()) + } + if (lowbat.jo_testNotifySend()) { return 2; + } if (argc > 2 && !strcmp(argv[1], "--say")) { if (lowbat.jo_testEspeak()) { lowbat.jo_setMsg(argv[2]); |