From 3b994f54899e526fa9e86121ce9efb6ca299d629 Mon Sep 17 00:00:00 2001
From: JozanLeClerc <bousset.rudy@gmail.com>
Date: Wed, 4 Dec 2019 00:02:42 +0100
Subject: .gitignore C++ update, doing some debug

---
 .gitignore        | 70 +++++++++++++++++++++++++++++--------------------------
 inc/jo_lowbat.hpp |  4 ++--
 src/jo_notify.cpp |  8 +++----
 src/main.cpp      | 14 +++++------
 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);
-- 
cgit v1.2.3