diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2019-12-29 13:13:07 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2019-12-29 13:13:07 +0100 |
commit | 8d453fb28dc7c07f0453d8d1063e5d2e72b9a320 (patch) | |
tree | b7143d7595a797083da4fafe8334c2250404ce74 | |
parent | ls still not working (diff) | |
download | lowbat-gnu-8d453fb28dc7c07f0453d8d1063e5d2e72b9a320.tar.gz lowbat-gnu-8d453fb28dc7c07f0453d8d1063e5d2e72b9a320.tar.bz2 lowbat-gnu-8d453fb28dc7c07f0453d8d1063e5d2e72b9a320.tar.xz lowbat-gnu-8d453fb28dc7c07f0453d8d1063e5d2e72b9a320.tar.zst lowbat-gnu-8d453fb28dc7c07f0453d8d1063e5d2e72b9a320.zip |
oop rework in progress
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | inc/jo_lowbat.hpp | 10 | ||||
-rw-r--r-- | src/jo_lowbat.cpp | 13 | ||||
-rw-r--r-- | src/main.cpp | 7 |
4 files changed, 29 insertions, 8 deletions
@@ -12,6 +12,7 @@ TRGT_DIR = bin/ SRCS_NAME = main.cpp SRCS_NAME += jo_exec.cpp SRCS_NAME += jo_notify.cpp +SRCS_NAME += jo_lowbat.cpp SRCS = $(addprefix ${SRCS_DIR}, ${SRCS_NAME}) @@ -50,13 +51,11 @@ MANPREFIX = $(PREFIX)/share/man ${OBJS_DIR}%.o: ${SRCS_DIR}%.cpp ${INCS_DIR}${INCS} -ifeq ("$(wildcard ${OBJS_DIR})","") - ${MKDIR} ${OBJS_DIR} -endif + @${MKDIR} ${OBJS_DIR} ${CXX} ${CXXFLAGS} -I${INCS_DIR} -c -o $@ $< ${NAME}: ${OBJS} - ${MKDIR} ${TRGT_DIR} + @${MKDIR} ${TRGT_DIR} ${CXX} ${CXXFLAGS} -o ${TRGT_DIR}${NAME} ${OBJS} all: ${NAME} diff --git a/inc/jo_lowbat.hpp b/inc/jo_lowbat.hpp index fd00892..57da23a 100644 --- a/inc/jo_lowbat.hpp +++ b/inc/jo_lowbat.hpp @@ -2,9 +2,19 @@ #define JO_LOWBAT_HPP #include <string> +#include <cstdint> using namespace std; +class Lowbat { +public: + uint8_t jo_testAcpi(void); + int jo_notify(const string); + int jo_speak(const string); + string jo_exec(const char*); +private: +}; + int jo_notify(const string); int jo_speak (const string); string jo_exec (const char*); 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"); |