From b8cf55c28e131ebdcb0a32fe0e8c14fefebebcea Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Tue, 23 Aug 2011 17:26:02 +0200 Subject: Configureable fifo path See #149. --- contrib/config-example | 1 + contrib/pianobar.1 | 10 ++++++++-- src/main.c | 6 ++---- src/settings.c | 6 ++++++ src/settings.h | 1 + 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/contrib/config-example b/contrib/config-example index 0a52dd6..bcc1b47 100644 --- a/contrib/config-example +++ b/contrib/config-example @@ -37,6 +37,7 @@ #audio_format = mp3 #autostart_station = 123456 #event_command = /home/user/.config/pianobar/eventcmd +#fifo = /tmp/pianobar #sort = quickmix_10_name_az #love_icon = [+] #ban_icon = [-] diff --git a/contrib/pianobar.1 b/contrib/pianobar.1 index 4cbc17a..eae062f 100644 --- a/contrib/pianobar.1 +++ b/contrib/pianobar.1 @@ -176,6 +176,12 @@ will use this proxy. The music is streamed directly. File that is executed when event occurs. See section .B EVENTCMD +.TP +.B fifo = /home/user/.config/pianobar/ctl +Location of control fifo. Defaults to $XDG_CONFIG_HOME/pianobar/ctl (which is +usually the value above). See section +.B REMOTE CONTROL + .TP .B format_nowplaying_song = \[dq]%t\[dq] by \[dq]%a\[dq] on \[dq]%l\[dq]%r%@%s Now playing song message format. Available format characters are: @@ -267,8 +273,8 @@ can be controlled through a fifo. You have to create it yourself by executing mkfifo ~/.config/pianobar/ctl -Adjust the path if you set up a $XDG_CONFIG_HOME. Afterwards you can write -commands directly into the fifo. Example (next song): +Adjust the path if you set up a $XDG_CONFIG_HOME or changed the fifo setting. +Afterwards you can write commands directly into the fifo. Example (next song): echo -n 'n' > ~/.config/pianobar/ctl diff --git a/src/main.c b/src/main.c index ece6909..c103bdd 100644 --- a/src/main.c +++ b/src/main.c @@ -326,7 +326,6 @@ static void BarMainLoop (BarApp_t *app) { int main (int argc, char **argv) { static BarApp_t app; - char ctlPath[PATH_MAX]; /* terminal attributes _before_ we started messing around with ~ECHO */ struct termios termOrig; @@ -363,14 +362,13 @@ int main (int argc, char **argv) { app.input.fds[0] = STDIN_FILENO; FD_SET(app.input.fds[0], &app.input.set); - BarGetXdgConfigDir (PACKAGE "/ctl", ctlPath, sizeof (ctlPath)); /* open fifo read/write so it won't EOF if nobody writes to it */ assert (sizeof (app.input.fds) / sizeof (*app.input.fds) >= 2); - app.input.fds[1] = open (ctlPath, O_RDWR); + app.input.fds[1] = open (app.settings.fifo, O_RDWR); if (app.input.fds[1] != -1) { FD_SET(app.input.fds[1], &app.input.set); BarUiMsg (&app.settings, MSG_INFO, "Control fifo at %s opened\n", - ctlPath); + app.settings.fifo); } app.input.maxfd = app.input.fds[0] > app.input.fds[1] ? app.input.fds[0] : app.input.fds[1]; diff --git a/src/settings.c b/src/settings.c index ea17985..49d75e6 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->fifo); for (size_t i = 0; i < MSG_COUNT; i++) { free (settings->msgFormat[i].prefix); free (settings->msgFormat[i].postfix); @@ -126,6 +127,8 @@ 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->fifo = malloc (PATH_MAX * sizeof (*settings->fifo)); + BarGetXdgConfigDir (PACKAGE "/ctl", settings->fifo, PATH_MAX); settings->msgFormat[MSG_NONE].prefix = NULL; settings->msgFormat[MSG_NONE].postfix = NULL; @@ -228,6 +231,9 @@ void BarSettingsRead (BarSettings_t *settings) { } else if (streq ("format_nowplaying_station", key)) { free (settings->npStationFormat); settings->npStationFormat = strdup (val); + } else if (streq ("fifo", key)) { + free (settings->fifo); + settings->fifo = strdup (val); } else if (strncmp (formatMsgPrefix, key, strlen (formatMsgPrefix)) == 0) { static const char *mapping[] = {"none", "info", "nowplaying", diff --git a/src/settings.h b/src/settings.h index af616a2..ca5db60 100644 --- a/src/settings.h +++ b/src/settings.h @@ -94,6 +94,7 @@ typedef struct { char *atIcon; char *npSongFormat; char *npStationFormat; + char *fifo; BarMsgFormatStr_t msgFormat[MSG_COUNT]; } BarSettings_t; -- cgit v1.2.3