nixos-configs/devices/wim/config/ags/js/osd/audio.js

31 lines
886 B
JavaScript
Raw Normal View History

2023-11-10 23:51:50 -05:00
import Audio from 'resource:///com/github/Aylur/ags/service/audio.js';
import { Box, Icon, ProgressBar } from 'resource:///com/github/Aylur/ags/widget.js';
import { SpeakerIcon } from '../misc/audio-icons.js';
2023-11-10 23:51:50 -05:00
export default () => Box({
className: 'osd',
children: [
Icon({
hpack: 'start',
binds: [['icon', SpeakerIcon, 'value']],
}),
ProgressBar({
vpack: 'center',
2023-11-10 23:51:50 -05:00
connections: [[Audio, self => {
if (!Audio.speaker)
return;
self.value = Audio.speaker ? Audio.speaker.volume / 1.5 : 0;
self.sensitive = !Audio.speaker?.stream.isMuted;
2023-11-10 23:51:50 -05:00
const stack = self.get_parent().get_parent();
stack.shown = 'audio';
stack.resetTimer();
}, 'speaker-changed']],
}),
],
});