summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/settings.c5
-rw-r--r--src/settings.h1
-rw-r--r--src/ui.c31
3 files changed, 32 insertions, 5 deletions
diff --git a/src/settings.c b/src/settings.c
index 49d75e6..9867b47 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -91,6 +91,7 @@ void BarSettingsDestroy (BarSettings_t *settings) {
free (settings->atIcon);
free (settings->npSongFormat);
free (settings->npStationFormat);
+ free (settings->listSongFormat);
free (settings->fifo);
for (size_t i = 0; i < MSG_COUNT; i++) {
free (settings->msgFormat[i].prefix);
@@ -127,6 +128,7 @@ void BarSettingsRead (BarSettings_t *settings) {
settings->atIcon = strdup (" @ ");
settings->npSongFormat = strdup ("\"%t\" by \"%a\" on \"%l\"%r%@%s");
settings->npStationFormat = strdup ("Station \"%n\" (%i)");
+ settings->listSongFormat = strdup ("%i) %a - %t%r");
settings->fifo = malloc (PATH_MAX * sizeof (*settings->fifo));
BarGetXdgConfigDir (PACKAGE "/ctl", settings->fifo, PATH_MAX);
@@ -231,6 +233,9 @@ void BarSettingsRead (BarSettings_t *settings) {
} else if (streq ("format_nowplaying_station", key)) {
free (settings->npStationFormat);
settings->npStationFormat = strdup (val);
+ } else if (streq ("format_list_song", key)) {
+ free (settings->listSongFormat);
+ settings->listSongFormat = strdup (val);
} else if (streq ("fifo", key)) {
free (settings->fifo);
settings->fifo = strdup (val);
diff --git a/src/settings.h b/src/settings.h
index ca5db60..6162395 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -94,6 +94,7 @@ typedef struct {
char *atIcon;
char *npSongFormat;
char *npStationFormat;
+ char *listSongFormat;
char *fifo;
BarMsgFormatStr_t msgFormat[MSG_COUNT];
} BarSettings_t;
diff --git a/src/ui.c b/src/ui.c
index 68f0cd9..84117bb 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -723,6 +723,20 @@ inline void BarUiPrintSong (const BarSettings_t *settings,
BarUiMsg (settings, MSG_PLAYING, outstr);
}
+/* Incremets two digit ASCII counter
+ */
+static void BarUiIncDigits (char digits[3]) {
+ ++digits[1];
+ if (digits[1] == ':') {
+ digits[1] = '0';
+ digits[0] |= 0x30;
+ ++digits[0];
+ if (digits[0] == ':') {
+ digits[0] = ' ';
+ }
+ }
+}
+
/* Print list of songs
* @param pianobar settings
* @param linked list of songs
@@ -732,18 +746,25 @@ inline void BarUiPrintSong (const BarSettings_t *settings,
size_t BarUiListSongs (const BarSettings_t *settings,
const PianoSong_t *song, const char *filter) {
size_t i = 0;
+ char digits[3] = " 0";
while (song != NULL) {
if (filter == NULL ||
(filter != NULL && (BarStrCaseStr (song->artist, filter) != NULL ||
BarStrCaseStr (song->title, filter) != NULL))) {
- BarUiMsg (settings, MSG_LIST, "%2lu) %s - %s %s%s\n", i, song->artist,
- song->title,
- (song->rating == PIANO_RATE_LOVE) ? settings->loveIcon : "",
- (song->rating == PIANO_RATE_BAN) ? settings->banIcon : "");
+ char outstr[512];
+ const char *vals[] = {digits, song->artist, song->title,
+ (song->rating == PIANO_RATE_LOVE) ? settings->loveIcon :
+ ((song->rating == PIANO_RATE_BAN) ? settings->banIcon : "")};
+
+ BarUiCustomFormat (outstr, sizeof (outstr), settings->listSongFormat,
+ "iatr", vals);
+ BarUiAppendNewline (outstr, sizeof (outstr));
+ BarUiMsg (settings, MSG_LIST, outstr);
}
- song = song->next;
i++;
+ BarUiIncDigits (digits);
+ song = song->next;
}
return i;