From 7d66bc7b728c7663d2bbe3f80c94f280d9b7907b Mon Sep 17 00:00:00 2001 From: bjoernf Date: Tue, 15 Aug 2023 21:17:24 +0200 Subject: [PATCH] get home env var and evolution path for ics file --- README.md | 16 ++++++++++++++-- makefile | 8 ++++++++ src/main.c | 12 +++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4ff54d4..c230818 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ Show upcoming events of an .ics file. -Set the path to your .ics file in `src/main.c`: +At the moment the standard path to the ics file used by the email client `evolution` is used.\ +You can set the path to your .ics file in `src/main.c`: ``` const char ICS_PATH[] = "tests/calendar.ics"; ``` +(uncomment some lines after that) ``` @@ -20,4 +22,14 @@ make sudo make install ``` -#### TODO: improve Makefile +#### uninstall + +``` +sudo make uninstall +``` + +#### TODO + +- option -f to choose ics file +- improve makefile +- tests diff --git a/makefile b/makefile index 69cc659..6130f33 100644 --- a/makefile +++ b/makefile @@ -14,3 +14,11 @@ run: .PHONY: install install: a.out cp a.out /usr/local/bin/ics_analyzer + +.PHONY: clean +clean: + rm a.out + +.PHONY: uninstall +uninstall: + rm /usr/local/bin/ics_analyzer diff --git a/src/main.c b/src/main.c index 697a125..29a9a10 100644 --- a/src/main.c +++ b/src/main.c @@ -7,12 +7,22 @@ #include "seek_string_a.h" #include "remove_whitespace.h" #include +#include #include #include #include int main() { - const char ICS_PATH[] = "tests/calendar.ics"; + //const char ICS_PATH[] = "tests/calendar.ics"; + char *ICS_PATH; + char *HOME = getenv("HOME"); + + if (HOME != NULL) { + ICS_PATH = strcat(HOME, "/.local/share/evolution/calendar/system/calendar.ics"); + } else { + printf ("Environment variable HOME is not set.\n"); + return 1; + } char my_line[4096] = "";