64 lines
1.7 KiB
QML
64 lines
1.7 KiB
QML
import Quickshell.Services.Pipewire
|
|
import Quickshell.Io
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
import qs
|
|
import qs.widgets
|
|
import qs.settings
|
|
|
|
Rectangle {
|
|
id: root
|
|
color: clickHandler.containsMouse ? Colors.base02 : Colors.base01
|
|
property PwNode defaultAudio: Pipewire.ready ? Pipewire.preferredDefaultAudioSink : null
|
|
property bool mute: Pipewire.ready ? defaultAudio?.audio.muted : null
|
|
radius: Config.rounding
|
|
required property double moduleHeight
|
|
implicitHeight: moduleHeight
|
|
implicitWidth: pwLayout.implicitWidth + 16
|
|
function getVolumeIcon() {
|
|
let volume = Pipewire.ready ? root.defaultAudio.audio.volume : null;
|
|
if (root.mute) {
|
|
return "\ue04f";
|
|
}
|
|
if (volume <= 0.33) {
|
|
return "\ue04e";
|
|
}
|
|
if (volume <= 0.66) {
|
|
return "\ue04d";
|
|
}
|
|
if (volume >= 0.66) {
|
|
return "\ue050";
|
|
}
|
|
}
|
|
PwObjectTracker {
|
|
objects: [Pipewire.ready ? Pipewire.defaultAudioSink : null]
|
|
}
|
|
|
|
Process {
|
|
id: pavuLauncher
|
|
command: ["pavucontrol"]
|
|
running: false
|
|
}
|
|
|
|
RowLayout {
|
|
id: pwLayout
|
|
anchors.centerIn: root
|
|
spacing: 4
|
|
MaterialIcon {
|
|
text: root.getVolumeIcon()
|
|
opacity: root.defaultAudio?.audio.muted ? 0.6 : 1.0
|
|
}
|
|
StyledText {
|
|
text: Math.floor(root.defaultAudio?.audio.volume * 100) + "%"
|
|
opacity: root.defaultAudio?.audio.muted ? 0.6 : 1.0
|
|
}
|
|
}
|
|
MouseArea {
|
|
id: clickHandler
|
|
hoverEnabled: true
|
|
acceptedButtons: Qt.LeftButton
|
|
cursorShape: Qt.PointingHandCursor
|
|
anchors.fill: root
|
|
onClicked: pavuLauncher.running = true
|
|
}
|
|
}
|