Commit 1b770abe authored by minus's avatar minus

Add Chromium/Mumble/Soldat

parent 4124467e
......@@ -107,6 +107,30 @@ void button_qfav(enum button button, enum button_direction direction, void *user
write(fc->stdin, buf, n);
}
void mumble_rpc(const char *cmd) {
gchar *args[] = {"mumble", "rpc", cmd, NULL};
g_autoptr(GError) error = NULL;
g_spawn_async(NULL, args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error);
if (error != NULL) {
g_error ("Spawning child failed: %s", error->message);
}
}
void button_mumble_toggle(enum button button, enum button_direction direction, void *userdata) {
fprintf(stdout, "button pressed: %i dir=%i\n", button, direction);
if (direction != BUTTON_PRESS) return;
mumble_rpc("togglemute");
}
void button_mumble_pushtotalk(enum button button, enum button_direction direction, void *userdata) {
fprintf(stdout, "button pressed: %i dir=%i\n", button, direction);
if (direction == BUTTON_PRESS) {
mumble_rpc("unmute");
} else {
mumble_rpc("mute");
}
}
int main(int argc, char *argv[]) {
if (argc != 2) {
fprintf(stderr, "usage: %s CLIENT_ID\n", argv[0]);
......@@ -114,6 +138,9 @@ int main(int argc, char *argv[]) {
}
int source = atoi(argv[1]);
// mpd (1)
///////////
// keep track of speakers sink PA index
siso_add_name(&sinks, "speakers");
siso_add_name(&sinks, "headphones");
......@@ -134,6 +161,9 @@ int main(int argc, char *argv[]) {
encoder_callback_add(ENC1, encoder_volume, mpd);
// mpv (2)
///////////
struct siso_watch *mpv = siso_add_name(&sink_inputs, " - mpv");
mpv->userdata = &(struct show_mute_and_speakers_config){
.sp = &sp,
......@@ -147,6 +177,9 @@ int main(int argc, char *argv[]) {
encoder_callback_add(ENC2, encoder_volume, mpv);
// Firefox (3)
///////////
struct siso_watch *ff = siso_add_name(&sink_inputs, "AudioStream");
ff->userdata = &(struct show_mute_and_speakers_config){
.sp = &sp,
......@@ -160,6 +193,58 @@ int main(int argc, char *argv[]) {
encoder_callback_add(ENC3, encoder_volume, ff);
// Chromium (4)
///////////
struct siso_watch *chromium = siso_add_name(&sink_inputs, "Playback");
chromium->userdata = &(struct show_mute_and_speakers_config){
.sp = &sp,
.button_mute = TOP4,
.button_speakers = BOTTOM4,
};
chromium->volume_changed = show_mute_and_speakers;
button_callback_add(TOP4, button_mute, chromium);
button_callback_add(BOTTOM4, button_sink, chromium);
encoder_callback_add(ENC4, encoder_volume, chromium);
// Mumble (5)
///////////
struct siso_watch *mumble = siso_add_name(&sink_inputs, "Mumble Speakers");
mumble->userdata = &(struct show_mute_and_speakers_config){
.sp = &sp,
.button_mute = TOP5,
.button_speakers = BOTTOM5,
};
mumble->volume_changed = show_mute_and_speakers;
button_callback_add(TOP5, button_mumble_pushtotalk, NULL);
button_callback_add(BOTTOM5, button_mumble_toggle, NULL);
button_callback_add(ENCPRESS5, button_sink, mumble);
encoder_callback_add(ENC5, encoder_volume, mumble);
// Soldat (6)
///////////
struct siso_watch *soldat = siso_add_name(&sink_inputs, "audio stream #1");
soldat->userdata = &(struct show_mute_and_speakers_config){
.sp = &sp,
.button_mute = TOP6,
.button_speakers = BOTTOM6,
};
soldat->volume_changed = show_mute_and_speakers;
button_callback_add(TOP6, button_mute, soldat);
button_callback_add(BOTTOM6, button_sink, soldat);
encoder_callback_add(ENC6, encoder_volume, soldat);
// Stewdio (7)
///////////
gchar *args[] = {"stewdio-textcmd", "https://radio.stew.moe/api/", "minus", NULL};
int child_stdout, child_stdin;
g_autoptr(GError) error = NULL;
......@@ -185,6 +270,9 @@ int main(int argc, char *argv[]) {
button_callback_add(TOP7, button_qfav, &fc);
// Animebits (8)
///////////
gchar *args2[] = {"stewdio-textcmd", "https://radio.animebits.moe/api/", "mns", NULL};
int child_stdout2, child_stdin2;
g_autoptr(GError) error2 = NULL;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment