nixos-configs/devices/wim/config/ags/js/quick-settings/slider-box.js

68 lines
2.1 KiB
JavaScript
Raw Normal View History

import Audio from 'resource:///com/github/Aylur/ags/service/audio.js';
import { Box, Slider, Icon, EventBox } from 'resource:///com/github/Aylur/ags/widget.js';
import { SpeakerIcon } from '../misc/audio-icons.js';
export default () => Box({
className: 'slider-box',
vertical: true,
2023-11-06 18:37:23 -05:00
hpack: 'center',
children: [
Box({
className: 'slider',
2023-11-06 18:37:23 -05:00
vpack: 'start',
hpack: 'center',
children: [
Icon({
size: 26,
className: 'slider-label',
binds: [['icon', SpeakerIcon, 'value']],
}),
Slider({
connections: [[Audio, slider => {
if (Audio.speaker)
slider.value = Audio.speaker.volume;
}, 'speaker-changed']],
onChange: ({ value }) => Audio.speaker.volume = value,
max: 0.999,
draw_value: false,
}),
],
}),
Box({
className: 'slider',
2023-11-06 18:37:23 -05:00
vpack: 'start',
hpack: 'center',
children: [
Icon({
className: 'slider-label',
icon: 'display-brightness-symbolic',
}),
EventBox({
onHover: box => box.child._canChange = false,
onHoverLost: box => box.child._canChange = true,
child: Slider({
properties: [
['canChange', true],
],
onChange: ({ value }) => {
2023-11-10 23:51:50 -05:00
Brightness.screen = value;
},
2023-11-10 23:51:50 -05:00
connections: [[Brightness, slider => {
if (slider._canChange)
slider.value = Brightness.screen;
}, 'screen']],
draw_value: false,
}),
}),
],
}),
],
});