diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/jo_lowbat.cpp | 13 | ||||
-rw-r--r-- | src/main.cpp | 7 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/jo_lowbat.cpp b/src/jo_lowbat.cpp new file mode 100644 index 0000000..56fe655 --- /dev/null +++ b/src/jo_lowbat.cpp @@ -0,0 +1,13 @@ +#include <jo_lowbat.hpp> +#include <iostream> + +using namespace std; + +uint8_t +Lowbat::jo_testAcpi(void) { + if (system("acpi > /dev/null 2>&1")) { + cout << "acpi is not installed. Please install it in order to run lowbat." << endl; + return 1; + } + return 0; +} diff --git a/src/main.cpp b/src/main.cpp index 497ff40..62c20b8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,10 +14,9 @@ int main(int argc, const char *argv[]) { string batlvl; int batlvlint; - if (system("acpi > /dev/null 2>&1")) { - cout << "acpi is not installed. Please install it in order to run lowbat." << endl; - return 1; - } + Lowbat lowbat; + if (lowbat.jo_testAcpi()) + return (1); while (true) { cout << "Fetching batlvl: "; batlvl = jo_exec("acpi | awk '{print $4}' | rev | cut -c 3- | rev"); |