nixos-configs/modules/ags/config/widgets/bar/items/brightness.tsx

41 lines
1 KiB
TypeScript
Raw Normal View History

2024-11-03 23:35:53 -05:00
import { bind } from 'astal';
2025-01-29 17:46:36 -05:00
import { App } from 'astal/gtk3';
2024-11-03 23:35:53 -05:00
import Brightness from '../../../services/brightness';
2025-01-29 17:46:36 -05:00
import PopupWindow from '../../misc/popup-window';
2024-11-03 23:35:53 -05:00
export default () => {
const brightness = Brightness.get_default();
2024-11-03 23:35:53 -05:00
return (
2025-01-29 17:46:36 -05:00
<button
cursor="pointer"
className="bar-item brightness"
onButtonReleaseEvent={(self) => {
const win = App.get_window('win-brightness-slider') as PopupWindow;
win.set_x_pos(
self.get_allocation(),
'right',
);
win.set_visible(!win.get_visible());
}}
>
<overlay passThrough>
2024-11-03 23:35:53 -05:00
<circularprogress
startAt={0.75}
endAt={0.75}
value={bind(brightness, 'screen')}
2024-11-03 23:35:53 -05:00
rounded
/>
<icon icon={bind(brightness, 'screenIcon')} />
2024-11-03 23:35:53 -05:00
</overlay>
2025-01-29 17:46:36 -05:00
</button>
2024-11-03 23:35:53 -05:00
);
};