diff options
| author | Spencer Williams <spnw@plexwave.org> | 2025-04-14 15:29:50 -0400 | 
|---|---|---|
| committer | Spencer Williams <spnw@plexwave.org> | 2025-04-14 15:32:37 -0400 | 
| commit | d1e077458de7fca3753940a7fe21f9ace1f6bb56 (patch) | |
| tree | f15a47e66edfbdfaf86c08baf088fdb27af5d6ed | |
| parent | 462b8f84e1ecc8740f6dde2c4bb861c77b5ba55f (diff) | |
Add options to hide queue information
| -rw-r--r-- | mpc-bar.m | 23 | 
1 files changed, 17 insertions, 6 deletions
| @@ -48,9 +48,8 @@ static NSString *formatTime(unsigned int t) {  }  struct config { -  char *host; -  char *host, *format;    char *host, *format, *idle_message; +  int show_queue, show_queue_idle;    unsigned port;  }; @@ -66,6 +65,10 @@ static int handler(void *userdata, const char *section, const char *name,      c->format = strdup(value);    } else if (MATCH("display", "idle_message")) {      c->idle_message = strdup(value); +  } else if (MATCH("display", "show_queue")) { +    c->show_queue = (strcmp(value, "false") != 0); +  } else if (MATCH("display", "show_queue_idle")) { +    c->show_queue_idle = (strcmp(value, "false") != 0);    } else {      return 0;    } @@ -97,6 +100,8 @@ static int handler(void *userdata, const char *section, const char *name,    config.port = 0;    config.format = "[%name%: &[[%artist%|%performer%|%composer%|%albumartist%] - ]%title%]|%name%|[[%artist%|%performer%|%composer%|%albumartist%] - ]%title%|%file%";    config.idle_message = "No song playing"; +  config.show_queue = 1; +  config.show_queue_idle = -1;  }  - (void)readConfigFile {    const char *path = [[NSHomeDirectory() @@ -104,6 +109,9 @@ static int handler(void *userdata, const char *section, const char *name,    if (ini_parse(path, handler, &config) < 0) {      NSLog(@"Failed to read config file");    } +  if (config.show_queue_idle == -1) { +    config.show_queue_idle = config.show_queue; +  }  }  - (void)connect {    assert(connection == NULL); @@ -223,10 +231,13 @@ static int handler(void *userdata, const char *section, const char *name,    int song_pos = mpd_status_get_song_pos(status);    unsigned int queue_length = mpd_status_get_queue_length(status); -  if (song_pos < 0) -    [output appendFormat:@" (%u)", queue_length]; -  else -    [output appendFormat:@" (%u/%u)", song_pos + 1, queue_length]; + +  if ((active && config.show_queue) || (!active && config.show_queue_idle)) { +    if (song_pos < 0) +      [output appendFormat:@" (%u)", queue_length]; +    else +      [output appendFormat:@" (%u/%u)", song_pos + 1, queue_length]; +  }    if ([output length] > TITLE_MAX_LENGTH) {      int leftCount = (TITLE_MAX_LENGTH - 3) / 2; | 
