nixos-configs/modules/ags/config/widgets/bar/items/audio.tsx
matt1432 6ca0d7248b
All checks were successful
Discord / discord commits (push) Has been skipped
refactor: rename some flake attr directories
2024-12-16 15:51:41 -05:00

46 lines
1.2 KiB
TypeScript

import { bind } from 'astal';
import { App } from 'astal/gtk3';
import AstalWp from 'gi://AstalWp';
import PopupWindow from '../../misc/popup-window';
export default () => {
const speaker = AstalWp.get_default()?.audio.default_speaker;
if (!speaker) {
throw new Error('Could not find default audio devices.');
}
return (
<button
cursor="pointer"
className="bar-item audio"
onButtonReleaseEvent={(self) => {
const win = App.get_window('win-audio') as PopupWindow;
win.set_x_pos(
self.get_allocation(),
'right',
);
win.visible = !win.visible;
}}
>
<overlay passThrough>
<circularprogress
startAt={0.75}
endAt={0.75}
value={bind(speaker, 'volume')}
rounded
className={bind(speaker, 'mute').as((muted) => muted ? 'disabled' : '')}
/>
<icon icon={bind(speaker, 'volumeIcon')} />
</overlay>
</button>
);
};