fixed bug that changed the HOME env var inside the program

This commit is contained in:
2023-08-17 17:59:49 +02:00
parent de70866e1f
commit ba37d057fb
2 changed files with 5 additions and 11 deletions

8
main.c
View File

@@ -12,10 +12,12 @@
int main(int argc, char **argv) {
int countdown_min_total;
char *HOME = getenv("HOME");
char *audio_file = "";
char audio_file_path[256] = "";
if (HOME != NULL) {
audio_file = strcat(HOME, "/music/alarm-clock-elapsed.wav");
strcpy(audio_file_path, HOME);
strcat(audio_file_path, "/music/alarm-clock-elapsed.wav");
} else {
printf ("Can't find environment variable HOME!\n");
return 1;
@@ -59,7 +61,7 @@ int main(int argc, char **argv) {
}
printf ("THE TIME IS UP!\n");
play_raw_audio(audio_file);
play_raw_audio(audio_file_path);
return 0;
}