mpc-bar

macOS menu bar client for the Music Player Daemon
Log | Files | Refs | README | LICENSE

commit 462b8f84e1ecc8740f6dde2c4bb861c77b5ba55f
parent 0a5872e156c316c2bb51d1d70c27be5ec0cf60c8
Author: Spencer Williams <spnw@plexwave.org>
Date:   Mon, 14 Apr 2025 15:29:20 -0400

Add option to configure idle message

Diffstat:
Mmpc-bar.m | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/mpc-bar.m b/mpc-bar.m @@ -50,6 +50,7 @@ static NSString *formatTime(unsigned int t) { struct config { char *host; char *host, *format; + char *host, *format, *idle_message; unsigned port; }; @@ -63,6 +64,8 @@ static int handler(void *userdata, const char *section, const char *name, c->port = atoi(value); } else if (MATCH("display", "format")) { c->format = strdup(value); + } else if (MATCH("display", "idle_message")) { + c->idle_message = strdup(value); } else { return 0; } @@ -93,6 +96,7 @@ static int handler(void *userdata, const char *section, const char *name, config.host = NULL; config.port = 0; config.format = "[%name%: &[[%artist%|%performer%|%composer%|%albumartist%] - ]%title%]|%name%|[[%artist%|%performer%|%composer%|%albumartist%] - ]%title%|%file%"; + config.idle_message = "No song playing"; } - (void)readConfigFile { const char *path = [[NSHomeDirectory() @@ -211,7 +215,9 @@ static int handler(void *userdata, const char *section, const char *name, [output appendString:utf8String(s)]; free(s); } else { - [output setString:@"No song playing"]; + // FIXME: There's no point calling utf8String more than once, as + // idle_message never changes. + [output setString:utf8String(config.idle_message)]; [menuButton setImage:nil]; }