From f96bf2bafa0b88e025e8ec7b4f89a6c21e4b0880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=88=D0=BE=D0=B2=D0=B0=D0=BD=20=D0=82=D0=BE=D0=BA=D0=B8?= =?UTF-8?q?=D1=9B-=D0=A8=D1=83=D0=BC=D0=B0=D1=80=D0=B0=D1=86?= Date: Mon, 27 Sep 2021 21:34:47 +0200 Subject: [PATCH] Some stuff --- pomodoro.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/pomodoro.c b/pomodoro.c index 5facbbf..aab5120 100644 --- a/pomodoro.c +++ b/pomodoro.c @@ -1,7 +1,6 @@ #include #include #include -#include #include "config.h" #if STUDY_SESSION_25 @@ -23,16 +22,19 @@ #define TIMER_B 10 #endif + #define STUDY 0 #define BREAK 1 +char help_msg[] = "\n-s integer\t\tsets length of studying session, in minutes\n" + "-b integer\t\tsets length of breaks, in minutes\n" + "-r integer\t\tnumber of sessions\n" + "-h \t\tprints help message lol \n\n"; - -int n_repeat = 0, time_elapsed = 0, timer_s = TIMER_S, timer_b = TIMER_B, check = 0; +int n_repeat = 4, time_elapsed = 0, timer_s = TIMER_S, timer_b = TIMER_B, check = 0; long time_started = 0; -void get_stuff(void); void start_timer(int); void countdown(long, short, char*); @@ -50,19 +52,28 @@ int main(int argc, char *argv[]){ if( *(argv[i]+1) == 'b' ) timer_b = atoi(argv[i+1]); + if( *(argv[i]+1) == 'r' ) + n_repeat = atoi(argv[i+1]); + + + if( *(argv[i]+1) == 'h'){ + printf("%s", help_msg); + exit(0); + } + } } - get_stuff(); - + system("clear"); for(int i = 1; i <= n_repeat; i++){ - printf("Session %d\n\n", i); + printf("Session %d of %d\n\n", i, n_repeat); start_timer(STUDY); + system("notify-send 'POMODORO' 'IT IS TIME FOR A BREAK' "); start_timer(BREAK); printf("%c[3F%c[2K%c[G", 27, 27, 27); @@ -76,16 +87,6 @@ int main(int argc, char *argv[]){ -void get_stuff(void){ - - printf("Enter number of pomodoro sessions (%d minute periods with %d minute breaks) : ", timer_s, timer_b); - - if ( !(scanf("%d", &n_repeat)) ){ - printf("\n\nThat's not a number you globussaire\n\n"); - fprintf(stderr, 0); - } - -} void start_timer(int x){