diff options
| author | Spencer Williams <spnw@plexwave.org> | 2025-04-14 15:29:20 -0400 | 
|---|---|---|
| committer | Spencer Williams <spnw@plexwave.org> | 2025-04-14 15:29:20 -0400 | 
| commit | 462b8f84e1ecc8740f6dde2c4bb861c77b5ba55f (patch) | |
| tree | e31650cce2882d0f546f183d2cd2ce10229690ab | |
| parent | 0a5872e156c316c2bb51d1d70c27be5ec0cf60c8 (diff) | |
Add option to configure idle message
| -rw-r--r-- | mpc-bar.m | 8 | 
1 files changed, 7 insertions, 1 deletions
| @@ -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];    } | 
