import AstalWp from "gi://AstalWp" import { execAsync, Variable, bind } from "astal" import Dropdown from "./Dropdown" const speaker = AstalWp.get_default().audio.default_speaker! const mic = AstalWp.get_default().audio.default_microphone const speakerIcon = Variable.derive( [bind(speaker, "volume"), bind(speaker, "mute")], (volume, mute) => { if (mute || volume <= 0.01) return "audio-volume-muted-symbolic" if (volume < 0.33) return "audio-volume-low-symbolic" if (volume < 0.66) return "audio-volume-medium-symbolic" return "audio-volume-high-symbolic" }, ) const micIcon = mic ? Variable.derive([bind(mic, "volume"), bind(mic, "mute")], (volume, mute) => mute || volume <= 0.01 ? "microphone-sensitivity-muted-symbolic" : "microphone-sensitivity-high-symbolic", ) : null const actions = [ { icon: "system-lock-screen-symbolic", cmd: ["hyprlock"] }, { icon: "weather-clear-night-symbolic", cmd: ["systemctl", "suspend"] }, { icon: "system-log-out-symbolic", cmd: ["hyprctl", "dispatch", "exit"] }, { icon: "system-reboot-symbolic", cmd: ["systemctl", "reboot"] }, { icon: "system-shutdown-symbolic", cmd: ["systemctl", "poweroff"] }, ] export default function QuickSettings(gdkmonitor: Gdk.Monitor) { const open = Variable(false) const button = ( ) const popup = ( {actions.map((action) => ( ))} (speaker.volume = self.value)} /> {mic && micIcon && ( (mic.volume = self.value)} /> )} ) return { button, popup } }