nixos-configs/config/ags/js/bar/brightness.js

36 lines
792 B
JavaScript
Raw Normal View History

2023-09-26 13:33:30 -04:00
const { ProgressBar, Overlay, Box } = ags.Widget;
const { execAsync } = ags.Utils;
2023-09-11 19:57:21 -04:00
import { Separator } from '../misc/separator.js';
import { Heart } from './heart.js';
2023-09-08 15:15:04 -04:00
export const Brightness = Overlay({
setup: widget => {
widget.set_tooltip_text('Brightness');
},
child: ProgressBar({
className: 'toggle-off brightness',
connections: [
[200, progress => {
2023-09-26 13:33:30 -04:00
execAsync('brightnessctl get').then(out => {
let br = out / 255;
if (br > 0.33) {
progress.value = br;
}
else {
progress.value = 0.33;
}
}).catch(print);
}],
],
}),
overlays: [
Box({
style: 'color: #CBA6F7;',
children: [
Separator(25),
Heart,
],
}),
2023-09-08 15:15:04 -04:00
],
});