Skip to content

Commit

Permalink
[[email protected]] Separate cmd line evaluation and executed…
Browse files Browse the repository at this point in the history
… on settings change (#6651)
  • Loading branch information
lrademacher authored Nov 29, 2024
1 parent bb34928 commit 9290717
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions [email protected]/files/[email protected]/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function findFirstMatch(searchStrings, checkString) {
MyApplet.prototype = {
__proto__: Applet.IconApplet.prototype,

_init: async function(metadata, orientation, panel_height, instance_id) {
_init: function(metadata, orientation, panel_height, instance_id) {
try {
this.settings = new Settings.AppletSettings(this, UUID, instance_id);
VERBOSE = this.settings.getValue("verbose");
Expand Down Expand Up @@ -114,23 +114,6 @@ MyApplet.prototype = {
this.on_settings_changed();
}

this.amixer = "amixer";
await this.evaluate_soundcard();
await this.evaluate_input();

const parameters = ["", " -D pulse"];
for (let param of parameters) {
let cmd = this.amixer + param + " scontrols";
log("Test mixer command '" + cmd + "'");
// TODO: Make it async.
let [res, stdout] = GLib.spawn_command_line_sync(cmd);
if (res && to_string(stdout).indexOf(this.input) != -1) {
this.amixer += param;
log("Use mixer command '" + this.amixer + "'");
break;
}
}

this.applet_is_running = true;
this.set_not_muted_icon();
this.is_audio_muted();
Expand All @@ -152,7 +135,7 @@ MyApplet.prototype = {
}

VERBOSE = this.verbose;
this.evaluate_soundcard();
this.evaluate_cmd_line();
},

refresh_loop: function() {
Expand Down Expand Up @@ -262,6 +245,25 @@ MyApplet.prototype = {
});
},

evaluate_cmd_line: async function() {
this.amixer = "amixer";
await this.evaluate_soundcard();
await this.evaluate_input();

const parameters = ["", " -D pulse"];
for (let param of parameters) {
let cmd = this.amixer + param + " scontrols";
log("Test mixer command '" + cmd + "'");
// TODO: Make it async.
let [res, stdout] = GLib.spawn_command_line_sync(cmd);
if (res && to_string(stdout).indexOf(this.input) != -1) {
this.amixer += param;
log("Use mixer command '" + this.amixer + "'");
break;
}
}
},

on_applet_clicked: function(event) {
try{
let cmd = [
Expand Down

0 comments on commit 9290717

Please sign in to comment.