aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--src/jo_notify.cpp3
-rw-r--r--src/main.cpp12
3 files changed, 9 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 406346e..7fe7c5a 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,8 @@ OPTIMIZE = -O3
CFLAGS = -Wall
CFLAGS += -Wextra
CFLAGS += -Werror
-CFLAGS += ${OPTIMIZE}
+CFLAGS += ${DEBUG}
+#CFLAGS += ${OPTIMIZE}
NAME = lowbat
diff --git a/src/jo_notify.cpp b/src/jo_notify.cpp
index 1c54a40..b357806 100644
--- a/src/jo_notify.cpp
+++ b/src/jo_notify.cpp
@@ -1,4 +1,5 @@
#include <jo_lowbat.hpp>
+#include <iostream>
int
jo_notify(const string batlvl) {
@@ -7,6 +8,7 @@ jo_notify(const string batlvl) {
str = "notify-send \"Low battery: ";
str += batlvl;
str += "%\" \"Please plug in computer\" -u critical -t 15000";
+ cout << "Notifying" << endl;
return system(str.c_str());
}
@@ -17,5 +19,6 @@ jo_speak(const string msg) {
str = "echo \"";
str += msg;
str += "\" | espeak";
+ cout << "Speaking" << endl;
return system(str.c_str());
}
diff --git a/src/main.cpp b/src/main.cpp
index 4a9cd64..36fe1b0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -12,31 +12,27 @@ int main(int argc, const char *argv[]) {
string* msg;
string acstat;
string batlvl;
- string arg_one;
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;
}
- if (argc > 1) {
- arg_one = argv[1];
- }
while (true) {
+ cout << "Fetching batlvl: ";
batlvl = jo_exec("acpi | awk '{print $4}' | rev | cut -c 3- | rev");
batlvl.erase(remove(batlvl.begin(), batlvl.end(), '\n'), batlvl.end());
batlvlint = stoi(batlvl);
+ cout << batlvlint << "%" << endl;
while (batlvlint < 25 && !system("acpi | grep -q Discharging")) {
- cout << "Notifying" << endl;
jo_notify(batlvl);
- if (strcmp(arg_one.c_str(), "--silent")) {
- if (argc > 2 && !strcmp(arg_one.c_str(), "--say")) {
+ if (argc > 1 && strcmp(argv[1], "--silent")) {
+ if (argc > 2 && !strcmp(argv[1], "--say")) {
msg = new string(argv[2]);
}
else {
msg = new string("beep beep - low battery");
}
- cout << "Speaking" << endl;
jo_speak(*msg);
delete msg;
}