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

91 lines
2.5 KiB
JavaScript
Raw Normal View History

import Audio from 'resource:///com/github/Aylur/ags/service/audio.js';
2023-11-16 15:02:00 -05:00
import { Box, Slider, Icon } from 'resource:///com/github/Aylur/ags/widget.js';
import Brightness from '../../services/brightness.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({
2023-11-16 15:02:00 -05:00
cursor: 'pointer',
vpack: 'center',
max: 0.999,
draw_value: false,
onChange: ({ value }) => {
Audio.speaker.volume = value;
},
2023-11-16 15:02:00 -05:00
connections: [
[Audio, (slider) => {
2023-11-16 15:02:00 -05:00
slider.value = Audio.speaker?.volume;
}, 'speaker-changed'],
['button-press-event', (s) => {
s.cursor = 'grabbing';
}],
['button-release-event', (s) => {
s.cursor = 'pointer';
}],
2023-11-16 15:02:00 -05:00
],
}),
],
}),
Box({
className: 'slider',
2023-11-06 18:37:23 -05:00
vpack: 'start',
hpack: 'center',
children: [
Icon({
className: 'slider-label',
icon: 'display-brightness-symbolic',
}),
2023-11-16 15:02:00 -05:00
Slider({
cursor: 'pointer',
vpack: 'center',
draw_value: false,
onChange: ({ value }) => {
Brightness.screen = value;
},
2023-11-16 15:02:00 -05:00
connections: [
[Brightness, (slider) => {
2023-11-16 15:02:00 -05:00
slider.value = Brightness.screen;
}, 'screen'],
['button-press-event', (s) => {
s.cursor = 'grabbing';
}],
['button-release-event', (s) => {
s.cursor = 'pointer';
}],
2023-11-16 15:02:00 -05:00
],
}),
],
}),
],
});