nixos-configs/devices/wim/config/ags/js/bar/buttons/brightness.js

49 lines
1.1 KiB
JavaScript
Raw Normal View History

import { Box, EventBox, Icon, Label, Revealer } from 'resource:///com/github/Aylur/ags/widget.js';
import Brightness from '../../../services/brightness.js';
2023-11-16 00:48:50 -05:00
import Separator from '../../misc/separator.js';
const SPACING = 5;
2023-09-08 15:15:04 -04:00
export default () => {
2023-12-18 18:00:30 -05:00
const icon = Icon({
icon: Brightness.bind('screenIcon'),
});
const hoverRevLabel = Revealer({
transition: 'slide_right',
2023-12-18 18:00:30 -05:00
child: Box({
2023-12-18 18:00:30 -05:00
children: [
Separator(SPACING),
2023-12-18 18:00:30 -05:00
Label().hook(Brightness, (self) => {
self.label = `${Math.round(Brightness.screen * 100)}%`;
}, 'screen'),
],
}),
});
const widget = EventBox({
2023-12-18 18:00:30 -05:00
on_hover: () => {
hoverRevLabel.reveal_child = true;
},
2023-12-18 18:00:30 -05:00
on_hover_lost: () => {
hoverRevLabel.reveal_child = false;
},
2023-12-18 18:00:30 -05:00
child: Box({
2023-12-18 18:00:30 -05:00
class_name: 'brightness',
children: [
2023-12-18 18:00:30 -05:00
icon,
hoverRevLabel,
],
}),
});
return widget;
};