pomo

A simple pomodoro timer
Log | Files | Refs | README | LICENSE

commit 312bd09739ad15a89d1439e12bd4a635c561f77c
parent 168b4f092caff12d2dddcf24fd85718d48e44a9a
Author: NunoSempere <nuno.sempere@protonmail.com>
Date:   Sun, 20 Aug 2023 13:32:54 +0200

print time when changing period

Diffstat:
Apomo | 0
Mpomo.c | 17++++++++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/pomo b/pomo Binary files differ. diff --git a/pomo.c b/pomo.c @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <time.h> #define MAX_MSG_LEN 100 #define LEN(a) (sizeof(a) / sizeof(a[0])) @@ -34,6 +35,19 @@ void spawn(char *argv[]){ } } +void print_time_now(){ + time_t timer; + char buffer[26]; + struct tm* tm_info; + + timer = time(NULL); + tm_info = localtime(&timer); + + strftime(buffer, 26, "%Y-%m-%d %H:%M:%S", tm_info); + fprintf(stderr, "%s", buffer); + +} + void display_message(char *msg){ char sh_command[MAX_MSG_LEN]; snprintf(sh_command, MAX_MSG_LEN, "echo '%s' | sent", msg); // NOLINT: We are being carefull here by considering MAX_MSG_LEN explicitly. @@ -45,7 +59,8 @@ void display_message(char *msg){ NULL }; spawn(spawn_args); - // fprintf(stderr, "%s\n", msg); + print_time_now(); + fprintf(stderr, " | %s\n", msg); } int main(int argc, char *argv[]){