aboutsummaryrefslogtreecommitdiff
path: root/moc_x11.c
diff options
context:
space:
mode:
Diffstat (limited to 'moc_x11.c')
-rw-r--r--moc_x11.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/moc_x11.c b/moc_x11.c
index 76384aa..efff073 100644
--- a/moc_x11.c
+++ b/moc_x11.c
@@ -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);
}
};