50 lines
1.4 KiB
QML
50 lines
1.4 KiB
QML
import Quickshell.Services.Pipewire
|
|
import Quickshell.Widgets
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
import qs
|
|
import qs.widgets
|
|
import qs.settings
|
|
|
|
WrapperRectangle {
|
|
id: root
|
|
color: Colors.base01
|
|
required property int barHeight
|
|
property double vertMargin: barHeight / 4 - 4
|
|
property PwNode defaultAudio: Pipewire.ready ? Pipewire.preferredDefaultAudioSink : null
|
|
property bool mute: Pipewire.ready ? defaultAudio?.audio.muted : null
|
|
radius: Config.rounding
|
|
topMargin: vertMargin
|
|
bottomMargin: vertMargin
|
|
leftMargin: 8
|
|
rightMargin: 8
|
|
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]
|
|
}
|
|
child: RowLayout {
|
|
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
|
|
}
|
|
}
|
|
}
|