- AGS v3.1.0 (Astal/GTK3) Ghost Shell avec ghost mode (heartbeat + hover reveal) - Modules : clock, battery, volume (interactif), network, MPRIS, CPU/RAM, systray - Brain Power panel (Super + B) — lecture live focus/todos/session - tetardtek_ prompt avec curseur clignotant - Palette violet-chaton v2 documentée (Mitsuri Kanroji gradient magenta → green) - Autostart COSMIC via .desktop - Archive AGS v1 conservée pour référence
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
import AstalWp from "gi://AstalWp"
|
|
import { createBinding } from "ags"
|
|
|
|
export default function Volume() {
|
|
const speaker = AstalWp.get_default()!.defaultSpeaker!
|
|
|
|
const text = createBinding(speaker, "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 = createBinding(speaker, "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>
|
|
)
|
|
}
|