summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/config-example3
-rw-r--r--src/main.c3
-rw-r--r--src/pianobar.18
-rw-r--r--src/settings.c14
-rw-r--r--src/settings.h2
-rw-r--r--src/ui.c50
-rw-r--r--src/ui.h6
-rw-r--r--src/ui_act.c14
8 files changed, 73 insertions, 27 deletions
diff --git a/contrib/config-example b/contrib/config-example
index c13badd..f39d45d 100644
--- a/contrib/config-example
+++ b/contrib/config-example
@@ -36,4 +36,5 @@
#autostart_station = 123456
#event_command = /home/user/.config/pianobar/eventcmd
#sort = quickmix_10_name_az
-
+#love_icon = [+]
+#ban_icon = [-]
diff --git a/src/main.c b/src/main.c
index d401e65..b582baf 100644
--- a/src/main.c
+++ b/src/main.c
@@ -259,7 +259,8 @@ int main (int argc, char **argv) {
}
/* song ready to play */
if (app.playlist != NULL) {
- BarUiPrintSong (app.playlist, app.curStation->isQuickMix ?
+ BarUiPrintSong (&app.settings, app.playlist,
+ app.curStation->isQuickMix ?
PianoFindStationById (app.ph.stations,
app.playlist->stationId) : NULL);
diff --git a/src/pianobar.1 b/src/pianobar.1
index ac262ef..a27b606 100644
--- a/src/pianobar.1
+++ b/src/pianobar.1
@@ -140,6 +140,10 @@ or the key you defined in
.B act_songinfo.
.TP
+.B ban_icon = </3
+Icon for banned songs.
+
+.TP
.B control_proxy = http://host:port/
Non-american users need a proxy to use pandora.com. Only the xmlrpc interface
will use this proxy. The music is streamed directly.
@@ -154,6 +158,10 @@ File that is executed when event occurs. See section
Keep a history of the last n songs (5, by default). You can rate these songs.
.TP
+.B love_icon = <3
+Icon for loved songs.
+
+.TP
.B password = plaintext_password
Your pandora.com password. Plain-text.
diff --git a/src/settings.c b/src/settings.c
index d085aff..43d2ca4 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -77,6 +77,8 @@ void BarSettingsDestroy (BarSettings_t *settings) {
free (settings->password);
free (settings->autostartStation);
free (settings->eventCmd);
+ free (settings->loveIcon);
+ free (settings->banIcon);
memset (settings, 0, sizeof (*settings));
}
@@ -175,6 +177,10 @@ void BarSettingsRead (BarSettings_t *settings) {
break;
}
}
+ } else if (strcmp ("love_icon", key) == 0) {
+ settings->loveIcon = strdup (val);
+ } else if (strcmp ("ban_icon", key) == 0) {
+ settings->banIcon = strdup (val);
}
}
@@ -186,5 +192,13 @@ void BarSettingsRead (BarSettings_t *settings) {
}
}
+ /* use default strings */
+ if (settings->loveIcon == NULL) {
+ settings->loveIcon = strdup ("<3");
+ }
+ if (settings->banIcon == NULL) {
+ settings->banIcon = strdup ("</3");
+ }
+
fclose (configfd);
}
diff --git a/src/settings.h b/src/settings.h
index f977a47..078c337 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -77,6 +77,8 @@ typedef struct {
char keys[BAR_KS_COUNT];
char *autostartStation;
char *eventCmd;
+ char *loveIcon;
+ char *banIcon;
} BarSettings_t;
void BarSettingsInit (BarSettings_t *);
diff --git a/src/ui.c b/src/ui.c
index 480dc83..509cfa5 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -330,27 +330,24 @@ PianoStation_t *BarUiSelectStation (PianoHandle_t *ph, const char *prompt,
* @param song list
* @return pointer to selected item in song list or NULL
*/
-PianoSong_t *BarUiSelectSong (PianoSong_t *startSong, FILE *curFd) {
+PianoSong_t *BarUiSelectSong (const BarSettings_t *settings,
+ PianoSong_t *startSong, FILE *curFd) {
PianoSong_t *tmpSong = NULL;
int i = 0;
- /* print all songs */
- tmpSong = startSong;
- while (tmpSong != NULL) {
- BarUiMsg (MSG_LIST, "%2u) %s - %s\n", i, tmpSong->artist,
- tmpSong->title);
- i++;
- tmpSong = tmpSong->next;
- }
+ i = BarUiListSongs (settings, startSong);
+
BarUiMsg (MSG_QUESTION, "Select song: ");
if (BarReadlineInt (&i, curFd) == 0) {
return NULL;
}
+
tmpSong = startSong;
while (tmpSong != NULL && i > 0) {
tmpSong = tmpSong->next;
i--;
}
+
return tmpSong;
}
@@ -436,14 +433,16 @@ char *BarUiSelectMusicId (BarApp_t *app, FILE *curFd, char *similarToId) {
musicId = strdup (tmpArtist->musicId);
}
} else if (*selectBuf == 't') {
- tmpSong = BarUiSelectSong (searchResult.songs, curFd);
+ tmpSong = BarUiSelectSong (&app->settings, searchResult.songs,
+ curFd);
if (tmpSong != NULL) {
musicId = strdup (tmpSong->musicId);
}
}
} else if (searchResult.songs != NULL) {
/* songs found */
- tmpSong = BarUiSelectSong (searchResult.songs, curFd);
+ tmpSong = BarUiSelectSong (&app->settings, searchResult.songs,
+ curFd);
if (tmpSong != NULL) {
musicId = strdup (tmpSong->musicId);
}
@@ -539,14 +538,37 @@ inline void BarUiPrintStation (PianoStation_t *station) {
* @param the song
* @param alternative station info (show real station for quickmix, e.g.)
*/
-inline void BarUiPrintSong (PianoSong_t *song, PianoStation_t *station) {
- BarUiMsg (MSG_PLAYING, "\"%s\" by \"%s\" on \"%s\"%s%s%s\n",
+inline void BarUiPrintSong (const BarSettings_t *settings,
+ const PianoSong_t *song, const PianoStation_t *station) {
+ BarUiMsg (MSG_PLAYING, "\"%s\" by \"%s\" on \"%s\"%s%s%s%s\n",
song->title, song->artist, song->album,
- (song->rating == PIANO_RATE_LOVE) ? " <3" : "",
+ (song->rating == PIANO_RATE_LOVE) ? " " : "",
+ (song->rating == PIANO_RATE_LOVE) ? settings->loveIcon : "",
station != NULL ? " @ " : "",
station != NULL ? station->name : "");
}
+/* Print list of songs
+ * @param pianobar settings
+ * @param linked list of songs
+ * @return # of songs
+ */
+size_t BarUiListSongs (const BarSettings_t *settings,
+ const PianoSong_t *song) {
+ size_t i = 0;
+
+ while (song != NULL) {
+ BarUiMsg (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 : "");
+ song = song->next;
+ i++;
+ }
+
+ return i;
+}
+
/* Excute external event handler
* @param settings containing the cmdline
* @param event type
diff --git a/src/ui.h b/src/ui.h
index 9a4dcb5..582ab5c 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -38,12 +38,14 @@ void BarUiMsg (uiMsg_t type, const char *format, ...);
PianoReturn_t BarUiPrintPianoStatus (PianoReturn_t ret);
PianoStation_t *BarUiSelectStation (PianoHandle_t *, const char *,
BarStationSorting_t, FILE *);
-PianoSong_t *BarUiSelectSong (PianoSong_t *startSong, FILE *curFd);
+PianoSong_t *BarUiSelectSong (const BarSettings_t *, PianoSong_t *, FILE *);
PianoArtist_t *BarUiSelectArtist (PianoArtist_t *startArtist, FILE *curFd);
char *BarUiSelectMusicId (BarApp_t *, FILE *, char *);
void BarStationFromGenre (BarApp_t *, FILE *);
void BarUiPrintStation (PianoStation_t *);
-void BarUiPrintSong (PianoSong_t *, PianoStation_t *);
+void BarUiPrintSong (const BarSettings_t *, const PianoSong_t *,
+ const PianoStation_t *);
+size_t BarUiListSongs (const BarSettings_t *, const PianoSong_t *);
void BarUiStartEventCmd (const BarSettings_t *, const char *,
const PianoStation_t *, const PianoSong_t *, const struct audioPlayer *,
PianoReturn_t, WaitressReturn_t);
diff --git a/src/ui_act.c b/src/ui_act.c
index 0f66986..0f0cac2 100644
--- a/src/ui_act.c
+++ b/src/ui_act.c
@@ -254,7 +254,8 @@ BarUiActCallback(BarUiActSongInfo) {
BarUiPrintStation (app->curStation);
/* print real station if quickmix */
- BarUiPrintSong (app->playlist, app->curStation->isQuickMix ?
+ BarUiPrintSong (&app->settings, app->playlist,
+ app->curStation->isQuickMix ?
PianoFindStationById (app->ph.stations, app->playlist->stationId) :
NULL);
}
@@ -420,13 +421,7 @@ BarUiActCallback(BarUiActPrintUpcoming) {
PianoSong_t *nextSong = app->playlist->next;
if (nextSong != NULL) {
- int i = 0;
- while (nextSong != NULL) {
- BarUiMsg (MSG_LIST, "%2i) \"%s\" by \"%s\"\n", i, nextSong->title,
- nextSong->artist);
- nextSong = nextSong->next;
- i++;
- }
+ BarUiListSongs (&app->settings, nextSong);
} else {
BarUiMsg (MSG_INFO, "No songs in queue.\n");
}
@@ -472,7 +467,8 @@ BarUiActCallback(BarUiActHistory) {
PianoSong_t *selectedSong;
if (app->songHistory != NULL) {
- selectedSong = BarUiSelectSong (app->songHistory, curFd);
+ selectedSong = BarUiSelectSong (&app->settings, app->songHistory,
+ curFd);
if (selectedSong != NULL) {
/* use user-defined keybindings */
allowedBuf[0] = app->settings.keys[BAR_KS_LOVE];