Added support for song numbers in notifications.

This commit is contained in:
Elijah 2022-08-14 11:39:41 +00:00
parent bcf724c4a5
commit 2357944eca
3 changed files with 17 additions and 3 deletions

View file

@ -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"

View file

@ -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

View file

@ -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