Audio popups also showing up if the volume changes e.g. by keys (#557)

This commit is contained in:
end-4
2024-06-01 07:44:07 +07:00
committed by GitHub
@@ -59,6 +59,7 @@ export default (monitor = 0) => {
}, 'notify::screen-value'),
progressSetup: (self) => self.hook(Brightness[monitor], (progress) => {
const updateValue = Brightness[monitor].screen_value;
if (updateValue !== progress.value) Indicator.popup(1);
progress.value = updateValue;
}, 'notify::screen-value'),
});
@@ -67,7 +68,7 @@ export default (monitor = 0) => {
name: 'Volume',
extraClassName: 'osd-volume',
extraProgressClassName: 'osd-volume-progress',
attribute: { headphones: undefined },
attribute: { headphones: undefined , device: undefined},
nameSetup: (self) => Utils.timeout(1, () => {
const updateAudioDevice = (self) => {
const usingHeadphones = (Audio.speaker?.stream?.port)?.toLowerCase().includes('headphone');
@@ -86,7 +87,14 @@ export default (monitor = 0) => {
}),
progressSetup: (self) => self.hook(Audio, (progress) => {
const updateValue = Audio.speaker?.volume;
if (!isNaN(updateValue)) progress.value = updateValue;
const newDevice = (Audio.speaker?.name);
if (!isNaN(updateValue)) {
if (newDevice === volumeIndicator.attribute.device && updateValue !== progress.value) {
Indicator.popup(1);
}
progress.value = updateValue;
}
volumeIndicator.attribute.device = newDevice;
}),
});
return MarginRevealer({