lux-shell/modules/bar/components/Pipewire.qml
2025-07-30 09:46:02 -04:00

63 lines
1.5 KiB
QML

import qs.config
import qs.widgets
import QtQuick
import Quickshell.Services.Pipewire
StyledButton {
id: clickable
property var sink: Pipewire.defaultAudioSink
PwObjectTracker {
id: bound
objects: [clickable.sink]
}
onClicked: mouse => {
if (!sink) {
return;
}
if (mouse.button == Qt.LeftButton) {
sink.audio.muted = !sink?.audio.muted;
} else if (mouse.button == Qt.RightButton)
// show menu
{}
}
onWheel: event => {
if (event.angleDelta.y > 0) {
sink.audio.volume = Math.min(sink.audio.volume + 0.02, 1.0);
} else if (event.angleDelta.y < 0) {
sink.audio.volume -= 0.02;
}
}
states: [
State {
name: "muted"
when: clickable.sink?.audio.muted ?? false
PropertyChanges {
text {
icon: " "
}
}
},
State {
name: "off"
when: clickable.sink?.audio.volume <= 0
PropertyChanges {
text {
icon: " "
}
}
}
]
content: StyledText {
id: text
property string icon: " "
text: `${icon} ${(clickable.sink?.audio.volume * 100).toFixed()}%`
font.pixelSize: Dimensions.pipewire.fontSize
color: clickable.containsMouse ? Theme.palette.base300 : Theme.palette.basecontent
}
}