+ pulse_ctx = pa_context_new(&pmain_api, "ursaryd");
+ pa_context_set_state_callback(pulse_ctx, pulse_state_cb, NULL);
+ pa_context_connect(pulse_ctx, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL);
+}
+
+/*** High-level logic ***/
+
+static struct main_timer update_timer;
+
+static void update_ring_from_sink(int ring, const char *sink_name)
+{
+ struct pulse_sink *s = pulse_sink_by_name(sink_name);
+ if (!s)
+ {
+ noct_set_ring(ring, RING_MODE_SINGLE_ON, 0x7f);
+ noct_set_button(ring, 0);
+ return;
+ }
+
+ if (s->mute)
+ {
+ noct_set_ring(ring, RING_MODE_SINGLE_ON, 0x7f);
+ noct_set_button(ring, 1);
+ return;
+ }
+
+ double vol = pa_sw_volume_to_linear(s->volume);
+ vol = CLAMP(vol, 0, 1);
+ int val = 0x7f * vol;
+ val = CLAMP(val, 0, 0x7f);
+ noct_set_ring(ring, RING_MODE_LEFT, val);
+ noct_set_button(ring, 0);
+}
+
+static void do_update(struct main_timer *t)