1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-27 06:52:50 -05:00

Incorporate some system sounds

This commit is contained in:
bbedward
2025-10-13 22:38:13 -04:00
parent 381df1e949
commit b5e29cf50c
13 changed files with 538 additions and 0 deletions

View File

@@ -3,9 +3,11 @@ pragma Singleton
pragma ComponentBehavior: Bound
import QtQuick
import QtMultimedia
import Quickshell
import Quickshell.Io
import Quickshell.Services.Pipewire
import qs.Common
Singleton {
id: root
@@ -25,6 +27,32 @@ Singleton {
onTriggered: root.suppressOSD = false
}
MediaPlayer {
id: volumeChangeSound
source: Qt.resolvedUrl("../assets/sounds/freedesktop/audio-volume-change.oga")
audioOutput: AudioOutput {
volume: 1.0
}
}
Timer {
id: volumeSoundDebounce
interval: 50
repeat: false
onTriggered: {
if (SettingsData.soundsEnabled && SettingsData.soundVolumeChanged && !root.suppressOSD) {
volumeChangeSound.play()
}
}
}
Connections {
target: root.sink?.audio
function onVolumeChanged() {
volumeSoundDebounce.restart()
}
}
function displayName(node) {
if (!node) {
return ""

View File

@@ -3,13 +3,42 @@ pragma Singleton
pragma ComponentBehavior: Bound
import QtQuick
import QtMultimedia
import Quickshell
import Quickshell.Io
import Quickshell.Services.UPower
import qs.Common
Singleton {
id: root
property bool suppressSound: true
property bool previousPluggedState: false
Timer {
id: startupTimer
interval: 500
repeat: false
running: true
onTriggered: root.suppressSound = false
}
MediaPlayer {
id: powerPlugSound
source: Qt.resolvedUrl("../assets/sounds/plasma/power-plug.ogg")
audioOutput: AudioOutput {
volume: 1.0
}
}
MediaPlayer {
id: powerUnplugSound
source: Qt.resolvedUrl("../assets/sounds/plasma/power-unplug.ogg")
audioOutput: AudioOutput {
volume: 1.0
}
}
readonly property string preferredBatteryOverride: Quickshell.env("DMS_PREFERRED_BATTERY")
readonly property UPowerDevice device: {
@@ -24,6 +53,23 @@ Singleton {
readonly property bool isCharging: batteryAvailable && device.state === UPowerDeviceState.Charging && device.changeRate > 0
readonly property bool isPluggedIn: batteryAvailable && (device.state !== UPowerDeviceState.Discharging && device.state !== UPowerDeviceState.Empty)
readonly property bool isLowBattery: batteryAvailable && batteryLevel <= 20
onIsPluggedInChanged: {
if (suppressSound || !batteryAvailable) {
previousPluggedState = isPluggedIn
return
}
if (SettingsData.soundsEnabled && SettingsData.soundPluggedIn) {
if (isPluggedIn && !previousPluggedState) {
powerPlugSound.play()
} else if (!isPluggedIn && previousPluggedState) {
powerUnplugSound.play()
}
}
previousPluggedState = isPluggedIn
}
readonly property string batteryHealth: {
if (!batteryAvailable) {
return "N/A"

View File

@@ -3,6 +3,7 @@ pragma Singleton
pragma ComponentBehavior: Bound
import QtQuick
import QtMultimedia
import Quickshell
import Quickshell.Services.Notifications
import Quickshell.Widgets
@@ -198,6 +199,22 @@ Singleton {
property var expandedMessages: ({})
property bool popupsDisabled: false
MediaPlayer {
id: normalNotificationSound
source: Qt.resolvedUrl("../assets/sounds/freedesktop/message.oga")
audioOutput: AudioOutput {
volume: 1.0
}
}
MediaPlayer {
id: criticalNotificationSound
source: Qt.resolvedUrl("../assets/sounds/freedesktop/message-new-instant.oga")
audioOutput: AudioOutput {
volume: 1.0
}
}
NotificationServer {
id: server
@@ -225,6 +242,14 @@ Singleton {
}
}
if (SettingsData.soundsEnabled && SettingsData.soundNewNotification) {
if (notif.urgency === NotificationUrgency.Critical) {
criticalNotificationSound.play()
} else {
normalNotificationSound.play()
}
}
const shouldShowPopup = !root.popupsDisabled && !SessionData.doNotDisturb
const isTransient = notif.transient
const wrapper = notifComponent.createObject(root, {