]> mj.ucw.cz Git - ursary.git/blobdiff - ursaryd.c
Muting of sources
[ursary.git] / ursaryd.c
index c128e50cce4fd881f18aadafc9e0464a3931f9f4..50b50c541084a3baa049a17cc7dfe003978f9e8a 100644 (file)
--- a/ursaryd.c
+++ b/ursaryd.c
@@ -31,7 +31,7 @@
  *             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *     0       sink PCH        mute            switch to PCH
  *     1       sink BT         mute            switch to BT
- *     2       -               -               -
+ *     2       -               mic non-mute    -
  *     3       desk brightness -               desk lights on
  *     4       MPD             mute            MPD play/pause
  *     5       Albireo MPV     mute            MPD stop
@@ -44,6 +44,7 @@
 
 #define PCH_SINK "alsa_output.pci-0000_00_1f.3.analog-stereo"
 #define BT_SINK "bluez_sink.CC_98_8B_D0_8C_06.a2dp_sink"
+#define LOGI_SOURCE "alsa_input.usb-046d_Logitech_Webcam_C925e_EF163C5F-02.analog-stereo"
 
 /*** Sink controls ***/
 
@@ -367,6 +368,34 @@ static void update_default_sink_from_button(int button, int on)
     }
 }
 
+/*** Source mute controls ***/
+
+static void update_source_buttons(void)
+{
+  struct pulse_source *source = pulse_source_by_name(LOGI_SOURCE);
+  if (!source)
+    return;
+
+  // if (source->suspended || source->mute)
+  if (source->mute)
+    noct_set_button(2, 0);
+  else
+    noct_set_button(2, 1);
+}
+
+static void update_source_mute_from_button(int on, const char *source_name)
+{
+  if (!on)
+    return;
+
+  struct pulse_source *s = pulse_source_by_name(source_name);
+  if (!s)
+    return;
+
+  DBG("## Setting mute of source %s to %d", s->name, !s->mute);
+  pulse_source_set_mute(s->idx, !s->mute);
+}
+
 /*** MPD controls ***/
 
 static bool mpd_flash_state;
@@ -638,6 +667,7 @@ static void do_update(struct main_timer *t)
   update_ring_from_sink(1, BT_SINK);
   update_groups();
   update_default_sink();
+  update_source_buttons();
   update_mpd();
   update_lights();
 }
@@ -702,6 +732,9 @@ void notify_button(int button, int on)
     case 1:
       update_sink_mute_from_button(on, BT_SINK);
       break;
+    case 2:
+      update_source_mute_from_button(on, LOGI_SOURCE);
+      break;
     case 8:
     case 9:
       update_default_sink_from_button(button, on);