aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile21
-rw-r--r--asm/jo_f_percent.asm24
-rw-r--r--asm/jo_f_status.asm7
-rw-r--r--src/jo_main.c6
4 files changed, 40 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 839329f..bc3350e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,15 @@
+##########################################################################################
+#* *#
+#* File : Makefile /_________/ *#
+#* Author : Joe | *#
+#* Date : 04/2020 | *#
+#* Info : BSD Makefile | *#
+#* / | *#
+#* \ / *#
+#* \_____/ *#
+#* *#
+##########################################################################################
+
default: all
SHELL := /bin/sh
@@ -61,14 +73,7 @@ depend:
all: depend ${TARGET}
clean:
- ${RM} ${C_OBJS}
- ${RM} ${A_OBJS}
- ${RM} ${TARGET}.core
- ${RM} .depend
- ${RM} .depend.tmp
-
-fclean: clean
- ${RM} ${TARGET}
+ ${RM} ${C_OBJS} ${A_OBJS} ${TARGET}.core .depend .depend.tmp ${TARGET}
re: fclean all
diff --git a/asm/jo_f_percent.asm b/asm/jo_f_percent.asm
index 765ca99..76d792b 100644
--- a/asm/jo_f_percent.asm
+++ b/asm/jo_f_percent.asm
@@ -12,18 +12,36 @@
section .text
extern system
+ extern atoi
global jo_f_percent
jo_f_percent:
mov rdi, f_cmd
call system
+ mov rdi, pr_file
+ mov rsi, 0x0
+ mov rax, 0x5
+ syscall
+ jc err
+ mov rdi, rax
+ mov rsi, buff
+ mov rdx, 0x3
+ mov rax, 0x3
+ syscall
+ jc err
+ mov rax, 0x6
+ syscall
+ xor rax, rax
+ mov rdi, rsi
+ call atoi
retq
err:
- mov rax, 0xff
+ mov rax, 0xfe
retq
section .data
- f_cmd: db "apm -l > /tmp/lowbat.percent", 0x0
- buff: db 0x0, 0x0, 0x0, 0x0
+ f_cmd: db "apm -l > /tmp/lowbat.percent", 0x0
+ pr_file: db "/tmp/lowbat.percent", 0x0
+ buff: db 0x0, 0x0, 0x0, 0x0
diff --git a/asm/jo_f_status.asm b/asm/jo_f_status.asm
index 69fad67..326f58e 100644
--- a/asm/jo_f_status.asm
+++ b/asm/jo_f_status.asm
@@ -32,20 +32,17 @@ jo_f_status:
mov rdi, rax
mov rsi, buff
mov rdx, 0x1
- push rax
mov rax, 0x3
syscall
jc err
- pop rax
- mov rdi, rax
mov rax, 0x6
syscall
movsx rax, byte [rsi + 0x0]
- sub rax, 0x30 ; 48
+ sub rax, 0x30 ; 48
retq
err:
- mov rax, 0xff
+ mov rax, 0xfe
retq
section .data
diff --git a/src/jo_main.c b/src/jo_main.c
index 7ee0c83..f3e97f4 100644
--- a/src/jo_main.c
+++ b/src/jo_main.c
@@ -16,6 +16,7 @@
** Files prefixes
** --------------
** f: fetch
+** n: notify
*/
int
@@ -24,10 +25,11 @@ main(void)
int8_t status;
int8_t percent;
- if ((status = jo_f_status()) < 0) {
+ if ((status = jo_f_status()) == -2) {
return (JO_RET_RD_FAILED);
}
- if ((percent = jo_f_percent()) < 0) {
+ if ((percent = jo_f_percent()) == -3) {
+ printf("failed\n");
return (JO_RET_RD_FAILED);
}
printf("status: %hhd, %hhd%%\n", status, percent);