Skip to content

Commit

Permalink
Control all inputs
Browse files Browse the repository at this point in the history
Adds a setting to control all inputs. This mutes and unmutes all
sources, instead of just the default.

Fixes wbolster#32
  • Loading branch information
BenignBeppe committed Apr 23, 2022
1 parent 9bb910a commit 3f5cd10
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
11 changes: 9 additions & 2 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,15 @@ class Microphone {
}

set muted(muted) {
if (!this.stream) return;
this.stream.change_is_muted(muted);
const controllAllInputs = settings.get_boolean("control-all-inputs");
if (controllAllInputs) {
const sources = this.mixer_control.get_sources();
for(let source of sources) {
source.change_is_muted(muted);
}
} else if (this.stream) {
this.stream.change_is_muted(muted);
}
}

get level() {
Expand Down
20 changes: 20 additions & 0 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,26 @@ function buildPrefsWidget() {
prefsWidget.attach(playingSoundNotSupportedLabel, 0, 5, 1, 1);
}

const controlAllInputsLabel = new Gtk.Label({
label: "Mute and unmute all microphones",
halign: Gtk.Align.START,
visible: true,
});
prefsWidget.attach(controlAllInputsLabel, 0, 6, 1, 1);

const controlAllInputsSwitch = new Gtk.Switch({
active: this.settings.get_boolean("control-all-inputs"),
halign: Gtk.Align.END,
visible: true,
});
this.settings.bind(
"control-all-inputs",
controlAllInputsSwitch,
"active",
Gio.SettingsBindFlags.DEFAULT
);
prefsWidget.attach(controlAllInputsSwitch, 1, 6, 1, 1);

if (GTK_VERSION == 3) {
prefsWidget.show_all();
}
Expand Down
Binary file modified schemas/gschemas.compiled
Binary file not shown.
5 changes: 5 additions & 0 deletions schemas/org.gnome.shell.extensions.nothing-to-say.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@
<summary>Play sound when muting and unmuting</summary>
<description>Play sounds when the microphone is muted and unmuted.</description>
</key>
<key name="control-all-inputs" type="b">
<default>false</default>
<summary>Mute and unmute all microphones</summary>
<description>All inputs are muted and unmuted if true. Otherwise only the default input is</description>
</key>
</schema>
</schemalist>

0 comments on commit 3f5cd10

Please sign in to comment.