Change sound muting behavior (#1342)

This commit is contained in:
end-4 2025-06-03 09:17:30 +02:00 committed by GitHub
commit b5ac985b7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 9 deletions

View file

@ -8,7 +8,7 @@ import Indicator from '../../services/indicator.js';
import { MaterialIcon } from '../.commonwidgets/materialicon.js';
const OsdValue = ({
name, icon, nameSetup = undefined, labelSetup, progressSetup,
name, icon, nameSetup = undefined, labelSetup, progressSetup, iconSetup,
extraClassName = '', extraProgressClassName = '',
...rest
}) => {
@ -31,7 +31,7 @@ const OsdValue = ({
}
},
children: [
MaterialIcon(icon, 'hugeass', {vpack: 'center'}),
MaterialIcon(icon, 'hugeass', {vpack: 'center', setup: iconSetup}),
Box({
vertical: true,
className: 'spacing-v-5',
@ -74,7 +74,6 @@ export default (monitor = 0) => {
const volumeIndicator = OsdValue({
name: 'Volume',
icon: 'volume_up',
extraClassName: 'osd-volume',
extraProgressClassName: 'osd-volume-progress',
attribute: { headphones: undefined , device: undefined},
@ -93,7 +92,9 @@ export default (monitor = 0) => {
}),
labelSetup: (self) => self.hook(Audio, (label) => {
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 (newDevice === volumeIndicator.attribute.device && updateValue != label.label) {
Indicator.popup(1);
@ -103,12 +104,20 @@ export default (monitor = 0) => {
label.label = `${updateValue}`;
}),
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 (updateValue > 1) progress.value = 1;
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({
transition: 'slide_down',

View file

@ -3,10 +3,11 @@
bindl = Alt ,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 = Super+Shift,M, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 0% # [hidden]
bindle=, XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ # [hidden]
bindle=, XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- # [hidden]
bindl = ,XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle # [hidden]
bindl = ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle # [hidden]
bindl = Super+Shift,M, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle # [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-mute @DEFAULT_AUDIO_SINK@ 0 && wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- # [hidden]
# Uncomment these if you can't get AGS to work
#bindle=, XF86MonBrightnessUp, exec, brightnessctl set '12.75+'