}
}
+/*** MPD controls ***/
+
+static void update_mpd(void)
+{
+ const char *state = mpd_get_player_state();
+ if (!strcmp(state, "play"))
+ noct_set_button(12, 1);
+ else
+ noct_set_button(12, 0);
+}
+
+static void mpd_button_timeout(struct main_timer *t)
+{
+ DBG("MPD stop");
+ timer_del(t);
+ mpd_stop();
+}
+
+static void update_mpd_from_button(int button UNUSED, int on)
+{
+ static struct main_timer mpd_button_timer = {
+ .handler = mpd_button_timeout,
+ };
+
+ if (!on)
+ {
+ timer_del(&mpd_button_timer);
+ return;
+ }
+
+ const char *state = mpd_get_player_state();
+ if (!strcmp(state, "stop"))
+ {
+ DBG("MPD play");
+ mpd_play();
+ }
+ else if (!strcmp(state, "play"))
+ {
+ DBG("MPD pause");
+ timer_add_rel(&mpd_button_timer, 1000);
+ mpd_pause(1);
+ }
+ else if (!strcmp(state, "pause"))
+ {
+ DBG("MPD resume");
+ mpd_pause(0);
+ }
+}
+
/*** Main update routines ***/
static struct main_timer update_timer;
update_ring_from_sink(1, "catarium");
update_clients();
update_default_sink();
+ update_mpd();
}
void schedule_update(void)
case 9:
update_default_sink_from_button(button, on);
break;
+ case 12:
+ update_mpd_from_button(button, on);
+ break;
default:
update_client_from_button(button, on);
}
noct_init();
pulse_init();
+ mpd_init();
msg(L_DEBUG, "Entering main loop");
main_loop();