nysh/src/AudioOutput.qml
Nydragon db3042111f
feat: hacky network and notification widget and caffeine widget
Network and notification widgets are just buttons to open nmtui and
swaync respectively... what they are doing in my waybar right now
anyways. Now I *should* not need waybar anymore.

Caffeine widget does what there is to do, set an inhibitor.

Restructured the project so that icons are in src/, screenshots are in
the renamed screenshots folder
2024-09-21 02:05:00 +02:00

87 lines
2.3 KiB
QML

import QtQuick
import QtQuick.Controls
import Quickshell
import Quickshell.Services.Pipewire
import "windows/audioman"
import "base"
// TODO: on click open detailed sink options:
// - select default sink
// - adjust sink & source volume
// - mute sinks & sources
BRectangle {
id: audiow
height: (icon.height + slider.height) * 1.5
property PwNode sink: Pipewire.defaultAudioSink
PwObjectTracker {
objects: [audiow.sink]
}
AudioManager {
id: audioman
}
MouseArea {
id: audio_area
anchors.fill: parent
onClicked: {
audioman.visible = !audioman.visible;
}
onWheel: wheel => {
const newVal = audiow.sink.audio.volume + (wheel.angleDelta.y / 12000);
sink.audio.volume = newVal < 1.0 ? (newVal > 0 ? newVal : 0.0) : 1.0;
}
Rectangle {
width: parent.width
color: "transparent"
height: icon.height + slider.height
anchors.verticalCenter: parent.verticalCenter
// TODO: Make icon depend on sink type and volume level
Image {
id: icon
source: "root:/assets/speaker.png"
width: parent.width * (2 / 3)
anchors.horizontalCenter: parent.horizontalCenter
fillMode: Image.PreserveAspectFit
}
Slider {
id: slider
anchors.top: icon.bottom
anchors.horizontalCenter: parent.horizontalCenter
height: background.height
width: parent.width * 0.75
enabled: false
value: audiow.sink?.audio.volume ?? 0
stepSize: 0.01
contentItem: Rectangle {
color: "#3191CD" // Change color based on value
radius: 5
width: slider.width * (slider.value / slider.to)
height: parent.height
}
background: Rectangle {
color: "#C4C4C4"
radius: 5
height: 4
anchors.bottomMargin: 5
anchors.topMargin: 5
}
handle: Rectangle {}
}
}
}
}