hyprland: drop quickshell/volume-osd

parent 040d135a
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Wayland
import Quickshell.Services.Pipewire
import Quickshell.Widgets
Scope {
id: root
PwObjectTracker {
objects: [ Pipewire.defaultAudioSink ]
}
Connections {
target: Pipewire.defaultAudioSink?.audio
function onMutedChanged() {
root.volume = target.muted ? 0 : target.volume
root.shouldShowOsd = true;
hideTimer.restart();
}
function onVolumeChanged() {
if (target.muted)
return
root.volume = (Pipewire.defaultAudioSink?.audio.volume ?? 0)
root.shouldShowOsd = true;
hideTimer.restart();
}
}
property bool shouldShowOsd: false
property real volume: 0.0
Timer {
id: hideTimer
interval: 1000
onTriggered: root.shouldShowOsd = false
}
LazyLoader {
active: root.shouldShowOsd
PanelWindow {
WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.exclusiveZone: -1
anchors.bottom: true
margins.bottom: screen.height / 20
implicitWidth: 300
implicitHeight: 40
color: "transparent"
mask: Region {}
Rectangle {
anchors.fill: parent
radius: height / 2
color: "#222226"
border.color: "#434347"
RowLayout {
anchors {
fill: parent
leftMargin: 15
rightMargin: 15
}
spacing: 10
Text {
id: volumeText
Layout.preferredWidth: 35
Layout.preferredHeight: 20
text: Math.round(root.volume * 100) + "%"
color: "white"
font.pixelSize: 14
font.bold: true
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 10
radius: 20
color: "#40D8E2EA"
Rectangle {
anchors {
left: parent.left
top: parent.top
bottom: parent.bottom
}
width: parent.width * root.volume
height: parent.height
radius: parent.radius
color: "white"
}
}
}
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment