nixos-configs/nixosModules/ags/config/widgets/bar/items/audio.tsx
matt1432 936e9aacb0
All checks were successful
Discord / discord commits (push) Has been skipped
feat(ags): add start of audio widget
2024-12-07 14:17:37 -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>
);
};