pipewire service

This commit is contained in:
Benjamin Palko 2025-07-31 09:53:50 -04:00
parent 38fce255d8
commit 89cf6f315b
2 changed files with 62 additions and 33 deletions

View file

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