gnome-shell-extension-bettervolume icon indicating copy to clipboard operation
gnome-shell-extension-bettervolume copied to clipboard

Unmute doesn't return to the pre-mute volume

Open vith opened this issue 8 years ago • 3 comments

When middle clicking to unmute, the volume changes from zero to seemingly the smallest value above zero.

vith avatar May 03 '16 19:05 vith

I can't really reproduce the behavior you're describing. :
What version of Gnome are you using?

Tudmotu avatar May 04 '16 13:05 Tudmotu

3.20.1 on Arch Linux

vith avatar May 04 '16 13:05 vith

I got it to work, sort of. Mute toggling works now but I don't know how to stop the aggregateMenu from opening. Also, the first middle click does nothing because stream is null the first time for some reason...

const Gvc = imports.gi.Gvc;
// Each Gvc.MixerControl is a connection to PulseAudio,
// so it's better to make it a singleton
let _mixerControl;
function getMixerControl() {
    if (_mixerControl)
        return _mixerControl;

    _mixerControl = new Gvc.MixerControl({ name: 'gnome-shell-extension-bettervolume Control' });
    _mixerControl.open();

    return _mixerControl;
}

let _previousVolumeValue, _previousVolumeIcon;
function _onVolumeIndicatorClick (actor, e) {
    // When middle-clicking on the indicator we want to toggle mute
    if (e.get_button() === Clutter.BUTTON_MIDDLE) {
        let control = getMixerControl();
        let stream = control.get_default_sink();
        if (!stream) return;
        stream.change_is_muted(stream && !stream.is_muted);
    }
}

Based on https://github.com/GNOME/gnome-shell/blob/master/js/ui/status/volume.js

vith avatar May 04 '16 15:05 vith