mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-05 21:15:38 -05:00
Tie volume OSD to dbus event
This commit is contained in:
@@ -30,7 +30,9 @@ Row {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
if (defaultSink) {
|
||||
AudioService.suppressOSD = true
|
||||
defaultSink.audio.muted = !defaultSink.audio.muted
|
||||
AudioService.suppressOSD = false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,6 +69,9 @@ Row {
|
||||
valueOverride: actualVolumePercent
|
||||
thumbOutlineColor: Theme.surfaceContainer
|
||||
trackColor: root.sliderTrackColor.a > 0 ? root.sliderTrackColor : Theme.surfaceContainerHigh
|
||||
onIsDraggingChanged: {
|
||||
AudioService.suppressOSD = isDragging
|
||||
}
|
||||
onSliderValueChanged: function(newValue) {
|
||||
if (defaultSink) {
|
||||
defaultSink.audio.volume = newValue / 100.0
|
||||
|
||||
@@ -30,7 +30,9 @@ Row {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
if (defaultSource) {
|
||||
AudioService.suppressOSD = true
|
||||
defaultSource.audio.muted = !defaultSource.audio.muted
|
||||
AudioService.suppressOSD = false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,6 +67,9 @@ Row {
|
||||
valueOverride: actualVolumePercent
|
||||
thumbOutlineColor: Theme.surfaceContainer
|
||||
trackColor: root.sliderTrackColor.a > 0 ? root.sliderTrackColor : Theme.surfaceContainerHigh
|
||||
onIsDraggingChanged: {
|
||||
AudioService.suppressOSD = isDragging
|
||||
}
|
||||
onSliderValueChanged: function(newValue) {
|
||||
if (defaultSource) {
|
||||
defaultSource.audio.volume = newValue / 100.0
|
||||
|
||||
@@ -12,12 +12,24 @@ DankOSD {
|
||||
enableMouseInteraction: true
|
||||
|
||||
Connections {
|
||||
target: AudioService
|
||||
target: AudioService.sink && AudioService.sink.audio ? AudioService.sink.audio : null
|
||||
|
||||
function onVolumeChanged() {
|
||||
root.show()
|
||||
if (!AudioService.suppressOSD) {
|
||||
root.show()
|
||||
}
|
||||
}
|
||||
|
||||
function onMutedChanged() {
|
||||
if (!AudioService.suppressOSD) {
|
||||
root.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: AudioService
|
||||
|
||||
function onSinkChanged() {
|
||||
if (root.shouldBeVisible) {
|
||||
root.show()
|
||||
|
||||
@@ -13,9 +13,18 @@ Singleton {
|
||||
readonly property PwNode sink: Pipewire.defaultAudioSink
|
||||
readonly property PwNode source: Pipewire.defaultAudioSource
|
||||
|
||||
signal volumeChanged
|
||||
property bool suppressOSD: true
|
||||
|
||||
signal micMuteChanged
|
||||
|
||||
Timer {
|
||||
id: startupTimer
|
||||
interval: 500
|
||||
repeat: false
|
||||
running: true
|
||||
onTriggered: root.suppressOSD = false
|
||||
}
|
||||
|
||||
function displayName(node) {
|
||||
if (!node) {
|
||||
return ""
|
||||
@@ -95,7 +104,6 @@ Singleton {
|
||||
|
||||
const clampedVolume = Math.max(0, Math.min(100, percentage))
|
||||
root.sink.audio.volume = clampedVolume / 100
|
||||
root.volumeChanged()
|
||||
return `Volume set to ${clampedVolume}%`
|
||||
}
|
||||
|
||||
@@ -148,7 +156,6 @@ Singleton {
|
||||
const newVolume = Math.max(0, Math.min(100, currentVolume + stepValue))
|
||||
|
||||
root.sink.audio.volume = newVolume / 100
|
||||
root.volumeChanged()
|
||||
return `Volume increased to ${newVolume}%`
|
||||
}
|
||||
|
||||
@@ -166,14 +173,11 @@ Singleton {
|
||||
const newVolume = Math.max(0, Math.min(100, currentVolume - stepValue))
|
||||
|
||||
root.sink.audio.volume = newVolume / 100
|
||||
root.volumeChanged()
|
||||
return `Volume decreased to ${newVolume}%`
|
||||
}
|
||||
|
||||
function mute(): string {
|
||||
const result = root.toggleMute()
|
||||
root.volumeChanged()
|
||||
return result
|
||||
return root.toggleMute()
|
||||
}
|
||||
|
||||
function setmic(percentage: string): string {
|
||||
|
||||
Reference in New Issue
Block a user