Audio WIP

This commit is contained in:
quadbyte 2025-08-10 18:48:04 -04:00
parent 5c7268aaee
commit 5e4530a403
2 changed files with 32 additions and 20 deletions

View file

@ -1,5 +1,6 @@
import QtQuick import QtQuick
import Quickshell import Quickshell
import Quickshell.Services.Pipewire
import qs.Services import qs.Services
import qs.Modules.Audio import qs.Modules.Audio
import qs.Widgets import qs.Widgets
@ -11,33 +12,40 @@ Item {
height: pillIndicator.height height: pillIndicator.height
function getIcon() { function getIcon() {
if (PipeWireAudio.muted) { if (Audio.muted) {
return "volume_off" return "volume_off"
} }
return PipeWireAudio.volume === 0 ? "volume_off" : (PipeWireAudio.volume < 0.33 ? "volume_down" : "volume_up") return Audio.volume === 0 ? "volume_off" : (Audio.volume < 0.33 ? "volume_down" : "volume_up")
} }
function getIconColor() { function getIconColor() {
if (PipeWireAudio.volume <= 1.0) { return (Audio.volume <= 1.0) ? Colors.textPrimary : getVolumeColor();
return Colors.textPrimary }
function getVolumeColor() {
if (Audio.volume <= 1.0) {
return Colors.accentPrimary
} }
// Indicate that the volume is over 100% // Indicate that the volume is over 100%
// Calculate interpolation factor (0 at 100%, 1.0 at 200%) // Calculate interpolation factor (0 at 100%, 1.0 at 200%)
let factor = (PipeWireAudio.volume - 1) let factor = (Audio.volume - 1.0)
// Blend between accent and warning colors // Blend between accent and warning colors
return Qt.rgba(Colors.textPrimary.r + (Colors.warning.r - Colors.textPrimary.r) * factor, return Qt.rgba(Colors.accentPrimary.r + (Colors.error.r - Colors.accentPrimary.r) * factor,
Colors.textPrimary.g + (Colors.warning.g - Colors.textPrimary.g) * factor, Colors.accentPrimary.g + (Colors.error.g - Colors.accentPrimary.g) * factor,
Colors.textPrimary.b + (Colors.warning.b - Colors.textPrimary.b) * factor, 1) Colors.accentPrimary.b + (Colors.error.b - Colors.accentPrimary.b) * factor, 1)
} }
NPill { NPill {
id: pillIndicator id: pillIndicator
icon: getIcon() icon: getIcon()
text: Math.round(PipeWireAudio.volume * 100) + "%" iconCircleColor: getVolumeColor()
collapsedIconColor: getIconColor()
autoHide: true
text: Math.round(Audio.volume * 100) + "%"
tooltipText: "Volume: " + Math.round( tooltipText: "Volume: " + Math.round(
PipeWireAudio.volume * 100) + "%\nLeft click for advanced settings.\nScroll up/down to change volume." Audio.volume * 100) + "%\nLeft click for advanced settings.\nScroll up/down to change volume."
onClicked: function () { onClicked: function () {
console.log("onClicked") console.log("onClicked")
//if (ioSelector.visible) { //if (ioSelector.visible) {
@ -46,13 +54,14 @@ Item {
// ioSelector.show(); // ioSelector.show();
// } // }
} }
}
// pillColor: Colors.surfaceVariant Connections {
// iconCircleColor: Colors.// getVolumeColor() target: Pipewire.defaultAudioSink?.audio ? Pipewire.defaultAudioSink?.audio : null
// iconTextColor: Colors.backgroundPrimary
// textColor: Colors.textPrimary function onVolumeChanged() {
// collapsedIconColor: getIconColor() console.log("[Bar:Volume] onVolumeChanged")
// autoHide: true }
} }
AudioDeviceSelector { AudioDeviceSelector {
@ -61,7 +70,7 @@ Item {
} }
// Connections { // Connections {
// target: PipeWireAudio // target: Audio
// function onVolumeChanged() { // function onVolumeChanged() {
// console.log("onVolumeChanged") // console.log("onVolumeChanged")
// } // }
@ -99,6 +108,4 @@ Item {
// } // }
// } // }
// } // }
// property bool containsMouse: false
} }

View file

@ -24,7 +24,12 @@ Singleton {
function onVolumeChanged() { function onVolumeChanged() {
root._volume = (Pipewire.defaultAudioSink?.audio.volume ?? 0) root._volume = (Pipewire.defaultAudioSink?.audio.volume ?? 0)
console.log("onVolumeChanged: " + volume) console.log("[Audio] onVolumeChanged: " + volume)
}
function onMutedChanged() {
root._muted = (Pipewire.defaultAudioSink?.audio.muted ?? true)
console.log("[Audio] onMuteChanged " + muted)
} }
} }
} }