2023-09-08 15:15:04 -04:00
|
|
|
const { Label, Icon, Stack, ProgressBar, Overlay, Box } = ags.Widget;
|
|
|
|
import { Separator } from '../common.js';
|
|
|
|
const { exec } = ags.Utils;
|
|
|
|
|
2023-09-10 00:39:43 -04:00
|
|
|
const Indicator = props => Icon({
|
2023-09-08 15:15:04 -04:00
|
|
|
...props,
|
2023-09-10 00:39:43 -04:00
|
|
|
size: 28,
|
|
|
|
style: 'margin-left: -5px',
|
|
|
|
icon: 'display-brightness-symbolic',
|
2023-09-08 15:15:04 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
const LevelLabel = props => Label({
|
|
|
|
...props,
|
|
|
|
className: 'label',
|
2023-09-10 00:39:43 -04:00
|
|
|
connections: [[200, label => label.label = `${Math.floor(exec('brightnessctl get') / 2.55)}%`]],
|
2023-09-08 15:15:04 -04:00
|
|
|
});
|
|
|
|
|
2023-09-10 00:39:43 -04:00
|
|
|
const BrightnessModule = () => Overlay({
|
|
|
|
child: ProgressBar({
|
|
|
|
className: 'toggle-off brightness',
|
|
|
|
connections: [
|
|
|
|
[ 200, progress => {
|
|
|
|
let br = exec('brightnessctl get') / 255;
|
|
|
|
if (br > 0.33) {
|
|
|
|
progress.value = br;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
progress.value = 0.33;
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
overlays: [
|
|
|
|
Box({
|
|
|
|
className: 'battery',
|
|
|
|
style: 'color: #CBA6F7;',
|
|
|
|
children: [
|
|
|
|
Indicator(),
|
|
|
|
Separator(2),
|
|
|
|
LevelLabel(),
|
|
|
|
],
|
|
|
|
}),
|
2023-09-08 15:15:04 -04:00
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
export const Brightness = BrightnessModule();
|