diff --git a/config.h b/config.h index 79ca0e7..a169156 100644 --- a/config.h +++ b/config.h @@ -17,6 +17,9 @@ * 1 - show notification * You must compile with NOTIFICATION=1 to enable this */ #define NOTIFICATION 1 +/* 0 - don't show song number in notifications + * 1 - show song number in notifications */ +#define SHOW_NUMBER 1 // Notification information #define APP_NAME "Pipeplayer" diff --git a/config.mk b/config.mk index 0a994c1..2e14f76 100644 --- a/config.mk +++ b/config.mk @@ -3,7 +3,7 @@ PREFIX = /usr/local MANPREFIX = $(PREFIX)/share/man # Name of program -VERSION = 1.4.0 +VERSION = 1.4.1 NAME = pipeplayer # Compiler diff --git a/playlist.c b/playlist.c index 1d738ce..7e3c228 100644 --- a/playlist.c +++ b/playlist.c @@ -55,6 +55,9 @@ load_playlist(struct playlist *playlist) { FILE *fp; ssize_t read; +#if NOTIFICATION == 1 && SHOW_NUMBER == 1 + size_t song_name_length; +#endif size_t length, len, count = 0; char *line = NULL; @@ -95,13 +98,21 @@ load_playlist(struct playlist *playlist) current->str = (char *) malloc(read + length); strncpy(current->str, playlist->dir, length); strncpy(current->str + length, line, read); + + count++; #if NOTIFICATION == 1 +#if SHOW_NUMBER == 1 + song_name_length = count / 10 + read; + current_name = new_node(current_name); + current_name->str = (char *) malloc(song_name_length); + snprintf(current_name->str, song_name_length - 1, "%lu. %s", count, line); +#else current_name = new_node(current_name); current_name->str = (char *) malloc(read - 4); strncpy(current_name->str, line, read - 5); -#endif - count++; +#endif /* SHOW_NUMBER == 1 */ +#endif /* NOTIFICATION == 1*/ } // Set playlist values