Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microphone level percentage not shown in the top bar #28

Open
krashish8 opened this issue Jan 12, 2021 · 2 comments
Open

Microphone level percentage not shown in the top bar #28

krashish8 opened this issue Jan 12, 2021 · 2 comments

Comments

@krashish8
Copy link

Thank you for this great extension! @wbolster

I could not find the percentage level of the microphone in the top bar, beside the microphone icon. Only the microphone icon is visible in the top bar. I am experiencing this in GNOME Shell 3.36.4 on Ubuntu 20.04.

Screenshot:
image

NB: The 50% which you see on the right is the speaker's sound percentage, made available using the sound-percentage gnome-shell extension.

@krashish8
Copy link
Author

krashish8 commented Jan 12, 2021

Nevermind, I understood that this is how the extension is supposed to behave. I somehow figured out how to do it myself.

A label needs to be created and inserted in the appropriate position, something like this:

const Clutter = imports.gi.Clutter;

function enable() {
  // ...
  let panel_button_label = new St.Label({
    y_expand: true,
    y_align: Clutter.ActorAlign.CENTER
  });
  panel_button_label.text = microphone.level + '%';
  Main.panel._rightBox.insert_child_at_index(panel_button_label, 0);
}

function disable() {
  // ...
  panel_button_label.destroy();
  panel_button_label = null;
}

Maybe this can be added as an option in dconf, if it is not of any general interest. I have some global shortcuts to adjust the microphone volume to some particular percentages, therefore this feature particularly interests me.

However, I cannot figure out how to update this microphone.level value each time the microphone level is updated by the global shortcut. Also, as of now, it displays 0% always.

Do you know a fix for this, or how to do this? @wbolster
Any link to understand this might be helpful. I guess I need to connect this to a signal, however, I don't know how to. I am new to gnome extensions. :)

@krashish8
Copy link
Author

Well, I somehow got it working locally by connecting to the notify signal of Gvc.MixerControl for the volume property:

refresh: function() {
  // ...
  this.stream.connect('notify::volume', (stream) => {
    this.notify_volume_change();
  });
  this.notify_volume_change();
  // ...
}

notify_volume_change: function() {
  this.emit('notify::volume_change');
},

// ...

def enable() {
  // ...
  microphone.connect(
    'notify::volume_change',
    function () {
      if (microphone.muted) {
        panel_button_label.text = '0%';
      } else {
        panel_button_label.text = microphone.level + '%';
      }
    });
  // ...
}

Thank you for this extension! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants