diff options
author | Calvin Morrison <calvin@fastmailteam.com> | 2022-07-27 22:24:04 -0400 |
---|---|---|
committer | Calvin Morrison <calvin@fastmailteam.com> | 2022-07-27 22:24:04 -0400 |
commit | ed51c35c9fc4c45c42f75c02323ffc1d8afa63b5 (patch) | |
tree | f64db8ded9db11573da0566b7e60d35b4743b61c /moc_x11.c | |
parent | 32838e89fc892ab8baa5d01294a9f90a0a21c4d5 (diff) |
update header and moc_x11.c to show length and server status
Diffstat (limited to 'moc_x11.c')
-rw-r--r-- | moc_x11.c | 41 |
1 files changed, 28 insertions, 13 deletions
@@ -110,34 +110,49 @@ int main() { XEvent e; while(1) { - int got_event = XNextEventTimed(dpy, &e, 250); + XNextEventTimed(dpy, &e, 250); + XClearWindow(dpy, win); if(mh->status != CONNECTED) { - printf("can't connect\n"); + XDrawString(dpy, win, DefaultGC(dpy, s), 0, 20, moc_str_status(mh->status), strlen(moc_str_status(mh->status))); + continue; } - XClearWindow(dpy, win); - int y_offset = 20; - int x = 10; - pthread_mutex_lock(&mh->lock); + int y_offset = 20; + int x = 10; + pthread_mutex_lock(&mh->lock); - XDrawString(dpy, win, DefaultGC(dpy, s), x, y_offset, moc_str_state(mh->state), strlen(moc_str_state(mh->state))); - y_offset += 15; - if(mh->state == PLAYING || mh->state == PAUSED) { - char *timestr= time_format(mh->time); + XDrawString(dpy, win, DefaultGC(dpy, s), x, y_offset, moc_str_state(mh->state), strlen(moc_str_state(mh->state))); + y_offset += 15; + if(mh->state == PLAYING || mh->state == PAUSED) { + if(mh->title) { XDrawString(dpy, win, DefaultGC(dpy, s), x, y_offset, mh->title, strlen(mh->title)); y_offset += 15; + } + if(mh->artist) { XDrawString(dpy, win, DefaultGC(dpy, s), x, y_offset, mh->artist, strlen(mh->artist)); y_offset += 15; + } + if(mh->artist) { XDrawString(dpy, win, DefaultGC(dpy, s), x, y_offset, mh->album, strlen(mh->album)); y_offset += 15; + } + if(mh->time >= 0) { + char *timestr= time_format(mh->time); + XDrawString(dpy, win, DefaultGC(dpy, s), x, y_offset, timestr, strlen(timestr)); + free(timestr); + y_offset += 15; + } + if(mh->length >= 0) { + char *timestr= time_format(mh->length); XDrawString(dpy, win, DefaultGC(dpy, s), x, y_offset, timestr, strlen(timestr)); + free(timestr); y_offset += 15; + } - free(timestr); - } - pthread_mutex_unlock(&mh->lock); + } + pthread_mutex_unlock(&mh->lock); } }; |