Files
dotfiles-violet-chaton/ags-v3/widget/modules/Volume.tsx
Tetardtek da22b6446d fix(ags-v3): audit fixes — portable brain path, reactive volume, SCSS dedup
- brain.ts: BRAIN_ROOT résolu via $BRAIN_ROOT env / ~/.config/brain-path / fallback ~/Dev/Brain
- Volume.tsx: bindings volume + mute séparés et réactifs
- style.scss: importe _bar.scss et _heartbeat.scss via @use, supprime 199 lignes dupliquées
2026-03-26 08:58:33 +01:00

45 lines
1.1 KiB
TypeScript

import AstalWp from "gi://AstalWp"
import { createBinding } from "ags"
export default function Volume() {
const speaker = AstalWp.get_default()!.defaultSpeaker!
const volume = createBinding(speaker, "volume")
const mute = createBinding(speaker, "mute")
const text = volume((v: number) => {
const pct = Math.round(v * 100)
const muted = speaker.mute
let icon = "󰕾"
if (muted) icon = "󰝟"
else if (v > 0.66) icon = "󰕾"
else if (v > 0.33) icon = "󰖀"
else if (v > 0) icon = "󰕿"
else icon = "󰝟"
return `${icon} ${pct}%`
})
const cls = mute((m: boolean) =>
m ? "volume muted" : "volume"
)
return (
<button
class={cls}
onClicked={() => {
speaker.mute = !speaker.mute
}}
onScroll={(_self: any, event: any) => {
const delta = event.delta_y
if (delta < 0) {
speaker.volume = Math.min(speaker.volume + 0.05, 1.0)
} else {
speaker.volume = Math.max(speaker.volume - 0.05, 0.0)
}
}}
>
<label label={text} />
</button>
)
}