49 lines
1.4 KiB
QML
49 lines
1.4 KiB
QML
// modules/AudioWidget.qml - wireplumber volume, matches waybar style.
|
|
// Icon set mirrors waybar wireplumber format-icons (NerdFont).
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
import Quickshell.Services.Pipewire
|
|
import ".."
|
|
|
|
Pill {
|
|
id: root
|
|
|
|
property var node: Pipewire.defaultAudioSink
|
|
property bool muted: node?.audio.muted ?? false
|
|
property real vol: node?.audio.volume ?? 0
|
|
|
|
property string icon: {
|
|
if (muted || vol === 0) return " "
|
|
if (vol < 0.34) return " "
|
|
if (vol < 0.67) return " "
|
|
return " "
|
|
}
|
|
|
|
onClicked: (m) => {
|
|
if (m.button === Qt.LeftButton) Exec.run(["pavucontrol"])
|
|
if (m.button === Qt.RightButton && node)
|
|
node.audio.muted = !node.audio.muted
|
|
}
|
|
|
|
onScrolled: (w) => {
|
|
if (!node) return
|
|
var delta = w.angleDelta.y > 0 ? 0.04 : -0.04
|
|
node.audio.volume = Math.max(0, Math.min(1.5, node.audio.volume + delta))
|
|
}
|
|
|
|
// Cava feeds into this on the left → right border only
|
|
leftPadding: 0
|
|
rightPadding: Theme.pillPadH
|
|
|
|
Text {
|
|
text: root.icon
|
|
font { family: Theme.fontMono; pixelSize: Theme.fontSize; }
|
|
color: "#fab387" // peach accent matching waybar foreground color for icon
|
|
}
|
|
Text {
|
|
text: root.muted ? "muted" : Math.round(root.vol * 100) + "%"
|
|
font { family: Theme.fontSans; pixelSize: Theme.fontSize }
|
|
color: Theme.foreground
|
|
}
|
|
}
|