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

47 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

2024-11-03 23:35:53 -05:00
import { bind } from 'astal';
2024-12-07 14:17:37 -05:00
import { App } from 'astal/gtk3';
2024-11-03 23:35:53 -05:00
import AstalWp from 'gi://AstalWp';
2024-12-07 14:17:37 -05:00
import PopupWindow from '../../misc/popup-window';
2024-11-03 23:35:53 -05:00
export default () => {
const speaker = AstalWp.get_default()?.audio.default_speaker;
if (!speaker) {
throw new Error('Could not find default audio devices.');
}
return (
2024-12-07 14:17:37 -05:00
<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>
2024-11-03 23:35:53 -05:00
<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>
2024-12-07 14:17:37 -05:00
</button>
2024-11-03 23:35:53 -05:00
);
};