aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2019-12-04 00:02:42 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2019-12-04 00:02:42 +0100
commit3b994f54899e526fa9e86121ce9efb6ca299d629 (patch)
treec2b69c1cdec49b081e3c2b390ec3366e8e9c8661
parentBetter include (diff)
downloadlowbat-gnu-3b994f54899e526fa9e86121ce9efb6ca299d629.tar.gz
lowbat-gnu-3b994f54899e526fa9e86121ce9efb6ca299d629.tar.bz2
lowbat-gnu-3b994f54899e526fa9e86121ce9efb6ca299d629.tar.xz
lowbat-gnu-3b994f54899e526fa9e86121ce9efb6ca299d629.tar.zst
lowbat-gnu-3b994f54899e526fa9e86121ce9efb6ca299d629.zip
.gitignore C++ update, doing some debug
-rw-r--r--.gitignore70
-rw-r--r--inc/jo_lowbat.hpp4
-rw-r--r--src/jo_notify.cpp8
-rw-r--r--src/main.cpp14
4 files changed, 50 insertions, 46 deletions
diff --git a/.gitignore b/.gitignore
index f67d8ad..ee1e3a5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,39 @@
-# Created by https://www.gitignore.io/api/zsh,linux,emacs
-# Edit at https://www.gitignore.io/?templates=zsh,linux,emacs
+# Created by https://www.gitignore.io/api/c++,linux,emacs
+# Edit at https://www.gitignore.io/?templates=c++,linux,emacs
+
+### C++ ###
+# Prerequisites
+*.d
+
+# Compiled Object files
+*.slo
+*.lo
+*.o
+*.obj
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Compiled Dynamic libraries
+*.so
+*.dylib
+*.dll
+
+# Fortran module files
+*.mod
+*.smod
+
+# Compiled Static libraries
+*.lai
+*.la
+*.a
+*.lib
+
+# Executables
+*.exe
+*.out
+*.app
### Emacs ###
# -*- mode: gitignore; -*-
@@ -66,37 +100,7 @@ flycheck_*.el
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
-### Zsh ###
-# Zsh compiled script + zrecompile backup
-*.zwc
-*.zwc.old
-
-# Zsh completion-optimization dumpfile
-*zcompdump*
-
-# Zsh zcalc history
-.zcalc_history
-
-# A popular plugin manager's files
-._zplugin
-.zplugin_lstupd
-
-# zdharma/zshelldoc tool's files
-zsdoc/data
-
-# robbyrussell/oh-my-zsh/plugins/per-directory-history plugin's files
-# (when set-up to store the history in the local directory)
-.directory_history
-
-# MichaelAquilina/zsh-autoswitch-virtualenv plugin's files
-# (for Zsh plugins using Python)
-.venv
-
-# Zunit tests' output
-/tests/_output/*
-!/tests/_output/.gitkeep
-
-# End of https://www.gitignore.io/api/zsh,linux,emacs
+# End of https://www.gitignore.io/api/c++,linux,emacs
bin/*
lowbat \ No newline at end of file
diff --git a/inc/jo_lowbat.hpp b/inc/jo_lowbat.hpp
index dc63275..9d9dfe8 100644
--- a/inc/jo_lowbat.hpp
+++ b/inc/jo_lowbat.hpp
@@ -15,8 +15,8 @@ using namespace std;
using namespace this_thread;
using namespace chrono;
-void jo_notify(const string);
-void jo_speak (const string);
+int jo_notify(const string);
+int jo_speak (const string);
string jo_exec (const char*);
#endif
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);