nova-shell/modules/Volume.qml
2026-04-11 00:35:37 +02:00

29 lines
762 B
QML

import QtQuick
import Quickshell.Services.Pipewire
import "." as M
Row {
id: root
spacing: 4
PwObjectTracker {
objects: [Pipewire.defaultAudioSink]
}
readonly property var sink: Pipewire.defaultAudioSink
readonly property real volume: sink?.audio?.volume ?? 0
readonly property bool muted: sink?.audio?.muted ?? false
M.BarIcon {
icon: root.muted ? "" : (root.volume > 0.5 ? "" : (root.volume > 0 ? "" : ""))
anchors.verticalCenter: parent.verticalCenter
}
M.BarLabel {
label: Math.round(root.volume * 100) + "%"
anchors.verticalCenter: parent.verticalCenter
}
TapHandler {
onTapped: if (root.sink?.audio) root.sink.audio.muted = !root.sink.audio.muted
}
}