repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by bugabinga
quickshell/nugu/VolumeWidget.qml
Rawimport QtQuick
import Quickshell.Services.Pipewire
import "."
StatusItem {
id: root
required property QtObject commands
readonly property var sink: Pipewire.defaultAudioSink
readonly property var audio: sink ? sink.audio : null
readonly property int percent: audio ? Math.round(audio.volume * 100) : 0
text: audio ? `${audio.muted ? "" : ""} ${percent}%` : ""
muted: audio ? audio.muted : true
minWidth: 52
// Tracker keeps the Pipewire node alive; otherwise the default sink object can
// disappear while the widget still has bindings to its audio interface.
PwObjectTracker { objects: [ Pipewire.defaultAudioSink ] }
onWheelUp: if (audio) audio.volume = Math.min(1.0, audio.volume + 0.02)
onWheelDown: if (audio) audio.volume = Math.max(0.0, audio.volume - 0.02)
onRightClicked: if (audio) audio.muted = !audio.muted
onMiddleClicked: commands.openAudioMixer()
}