From 6f7577467a5eea0531e4c89069665cc962ccebac Mon Sep 17 00:00:00 2001 From: Myryk Date: Wed, 29 May 2024 17:54:11 +0200 Subject: [PATCH 1/5] Indicator now pops up if volume changes --- .config/ags/modules/indicators/indicatorvalues.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.config/ags/modules/indicators/indicatorvalues.js b/.config/ags/modules/indicators/indicatorvalues.js index 5d8c1e680..8b5a15a4d 100644 --- a/.config/ags/modules/indicators/indicatorvalues.js +++ b/.config/ags/modules/indicators/indicatorvalues.js @@ -86,7 +86,10 @@ export default (monitor = 0) => { }), progressSetup: (self) => self.hook(Audio, (progress) => { const updateValue = Audio.speaker?.volume; - if (!isNaN(updateValue)) progress.value = updateValue; + if (!isNaN(updateValue)) { + if (updateValue != progress.value) Indicator.popup(1); + progress.value = updateValue; + } }), }); return MarginRevealer({ From cdf4b7dc06f35e23b0a5d7d31b0a1ebb1e2aa7f0 Mon Sep 17 00:00:00 2001 From: Myryk Date: Wed, 29 May 2024 18:04:23 +0200 Subject: [PATCH 2/5] brightness popup works as well --- .config/ags/modules/indicators/indicatorvalues.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.config/ags/modules/indicators/indicatorvalues.js b/.config/ags/modules/indicators/indicatorvalues.js index 8b5a15a4d..2eebfe50d 100644 --- a/.config/ags/modules/indicators/indicatorvalues.js +++ b/.config/ags/modules/indicators/indicatorvalues.js @@ -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'), }); From b2574cf2afb5a065e271e7c5046a9700c8e89bf8 Mon Sep 17 00:00:00 2001 From: Myryk Date: Wed, 29 May 2024 18:11:03 +0200 Subject: [PATCH 3/5] switched to strict inequality --- .config/ags/modules/indicators/indicatorvalues.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/ags/modules/indicators/indicatorvalues.js b/.config/ags/modules/indicators/indicatorvalues.js index 2eebfe50d..7012c82a9 100644 --- a/.config/ags/modules/indicators/indicatorvalues.js +++ b/.config/ags/modules/indicators/indicatorvalues.js @@ -59,7 +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); + if (updateValue !== progress.value) Indicator.popup(1); progress.value = updateValue; }, 'notify::screen-value'), }); @@ -88,7 +88,7 @@ export default (monitor = 0) => { progressSetup: (self) => self.hook(Audio, (progress) => { const updateValue = Audio.speaker?.volume; if (!isNaN(updateValue)) { - if (updateValue != progress.value) Indicator.popup(1); + if (updateValue !== progress.value) Indicator.popup(1); progress.value = updateValue; } }), From 8e20486e2e4dadeedeefd1e6b5b29ab9a2a58e9a Mon Sep 17 00:00:00 2001 From: Myryk Date: Fri, 31 May 2024 10:59:13 +0200 Subject: [PATCH 4/5] fixed unwanted popup when changing device --- .config/ags/modules/indicators/indicatorvalues.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.config/ags/modules/indicators/indicatorvalues.js b/.config/ags/modules/indicators/indicatorvalues.js index 7012c82a9..625634609 100644 --- a/.config/ags/modules/indicators/indicatorvalues.js +++ b/.config/ags/modules/indicators/indicatorvalues.js @@ -63,12 +63,11 @@ export default (monitor = 0) => { progress.value = updateValue; }, 'notify::screen-value'), }); - const volumeIndicator = OsdValue({ 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'); @@ -87,8 +86,14 @@ export default (monitor = 0) => { }), progressSetup: (self) => self.hook(Audio, (progress) => { const updateValue = Audio.speaker?.volume; + const newDevice = (Audio.speaker?.name); + // print(newDevice, device); if (!isNaN(updateValue)) { - if (updateValue !== progress.value) Indicator.popup(1); + if ((volumeIndicator.attribute.device === undefined || newDevice === volumeIndicator.attribute.device) + && updateValue !== progress.value) { + Indicator.popup(1); + } + volumeIndicator.attribute.device = newDevice; progress.value = updateValue; } }), From bb1cc5de0e49a2dee3243c4818db1078c9322a94 Mon Sep 17 00:00:00 2001 From: Myryk Date: Fri, 31 May 2024 11:08:11 +0200 Subject: [PATCH 5/5] structured my code better --- .config/ags/modules/indicators/indicatorvalues.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.config/ags/modules/indicators/indicatorvalues.js b/.config/ags/modules/indicators/indicatorvalues.js index 625634609..94b2d694b 100644 --- a/.config/ags/modules/indicators/indicatorvalues.js +++ b/.config/ags/modules/indicators/indicatorvalues.js @@ -63,6 +63,7 @@ export default (monitor = 0) => { progress.value = updateValue; }, 'notify::screen-value'), }); + const volumeIndicator = OsdValue({ name: 'Volume', extraClassName: 'osd-volume', @@ -87,15 +88,13 @@ export default (monitor = 0) => { progressSetup: (self) => self.hook(Audio, (progress) => { const updateValue = Audio.speaker?.volume; const newDevice = (Audio.speaker?.name); - // print(newDevice, device); if (!isNaN(updateValue)) { - if ((volumeIndicator.attribute.device === undefined || newDevice === volumeIndicator.attribute.device) - && updateValue !== progress.value) { - Indicator.popup(1); - } - volumeIndicator.attribute.device = newDevice; + if (newDevice === volumeIndicator.attribute.device && updateValue !== progress.value) { + Indicator.popup(1); + } progress.value = updateValue; } + volumeIndicator.attribute.device = newDevice; }), }); return MarginRevealer({