Enable sound unmuting and show the muted sound icon

This commit is contained in:
asalde_le1
2025-06-01 06:46:54 +03:00
parent f1cee49494
commit 277162f4d4
2 changed files with 18 additions and 9 deletions
@@ -8,7 +8,7 @@ import Indicator from '../../services/indicator.js';
import { MaterialIcon } from '../.commonwidgets/materialicon.js'; import { MaterialIcon } from '../.commonwidgets/materialicon.js';
const OsdValue = ({ const OsdValue = ({
name, icon, nameSetup = undefined, labelSetup, progressSetup, name, icon, nameSetup = undefined, labelSetup, progressSetup, iconSetup,
extraClassName = '', extraProgressClassName = '', extraClassName = '', extraProgressClassName = '',
...rest ...rest
}) => { }) => {
@@ -31,7 +31,7 @@ const OsdValue = ({
} }
}, },
children: [ children: [
MaterialIcon(icon, 'hugeass', {vpack: 'center'}), MaterialIcon(icon, 'hugeass', {vpack: 'center', setup: iconSetup}),
Box({ Box({
vertical: true, vertical: true,
className: 'spacing-v-5', className: 'spacing-v-5',
@@ -74,7 +74,6 @@ export default (monitor = 0) => {
const volumeIndicator = OsdValue({ const volumeIndicator = OsdValue({
name: 'Volume', name: 'Volume',
icon: 'volume_up',
extraClassName: 'osd-volume', extraClassName: 'osd-volume',
extraProgressClassName: 'osd-volume-progress', extraProgressClassName: 'osd-volume-progress',
attribute: { headphones: undefined , device: undefined}, attribute: { headphones: undefined , device: undefined},
@@ -93,7 +92,9 @@ export default (monitor = 0) => {
}), }),
labelSetup: (self) => self.hook(Audio, (label) => { labelSetup: (self) => self.hook(Audio, (label) => {
const newDevice = (Audio.speaker?.name); const newDevice = (Audio.speaker?.name);
const updateValue = Math.round(Audio.speaker?.volume * 100); const updateValue = Audio.speaker?.stream?.isMuted
? 0
: Math.round(Audio.speaker?.volume * 100);
if (!isNaN(updateValue)) { if (!isNaN(updateValue)) {
if (newDevice === volumeIndicator.attribute.device && updateValue != label.label) { if (newDevice === volumeIndicator.attribute.device && updateValue != label.label) {
Indicator.popup(1); Indicator.popup(1);
@@ -103,12 +104,20 @@ export default (monitor = 0) => {
label.label = `${updateValue}`; label.label = `${updateValue}`;
}), }),
progressSetup: (self) => self.hook(Audio, (progress) => { progressSetup: (self) => self.hook(Audio, (progress) => {
const updateValue = Audio.speaker?.volume; const updateValue = Audio.speaker?.stream?.isMuted
? 0
: Audio.speaker?.volume;
if (!isNaN(updateValue)) { if (!isNaN(updateValue)) {
if (updateValue > 1) progress.value = 1; if (updateValue > 1) progress.value = 1;
else progress.value = updateValue; else progress.value = updateValue;
} }
}), }),
iconSetup: (self) => self.hook(Audio, (progress) => {
self.label =
Audio.speaker?.stream?.isMuted || !Audio.speaker.volume
? 'volume_off'
: 'volume_up';
}),
}); });
return MarginRevealer({ return MarginRevealer({
transition: 'slide_down', transition: 'slide_down',
+4 -4
View File
@@ -3,10 +3,10 @@
bindl = Alt ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_SOURCE@ toggle # [hidden] bindl = Alt ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_SOURCE@ toggle # [hidden]
bindl = Super ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_SOURCE@ toggle # [hidden] bindl = Super ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_SOURCE@ toggle # [hidden]
bindl = ,XF86AudioMute, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 0% # [hidden] bindl = ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle # [hidden]
bindl = Super+Shift,M, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 0% # [hidden] bindl = Super+Shift,M, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle # [hidden]
bindle=, XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ # [hidden] bindle=, XF86AudioRaiseVolume, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 && wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ # [hidden]
bindle=, XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- # [hidden] bindle=, XF86AudioLowerVolume, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 && wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- # [hidden]
# Uncomment these if you can't get AGS to work # Uncomment these if you can't get AGS to work
#bindle=, XF86MonBrightnessUp, exec, brightnessctl set '12.75+' #bindle=, XF86MonBrightnessUp, exec, brightnessctl set '12.75+'