mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-05 21:15:38 -05:00
sounds: make qt6-multimedia optional
This commit is contained in:
@@ -1198,6 +1198,7 @@ Item {
|
||||
color: Theme.surfaceContainerHigh
|
||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
|
||||
border.width: 0
|
||||
visible: AudioService.soundsAvailable
|
||||
|
||||
Column {
|
||||
id: soundsSection
|
||||
|
||||
@@ -287,11 +287,11 @@ sudo sh -c "curl -L https://github.com/AvengeMedia/danklinux/releases/latest/dow
|
||||
**4.1 Core optional dependencies**
|
||||
```bash
|
||||
# Arch Linux
|
||||
sudo pacman -S cava wl-clipboard cliphist brightnessctl
|
||||
sudo pacman -S cava wl-clipboard cliphist brightnessctl qt6-multimedia
|
||||
paru -S matugen-bin dgop
|
||||
|
||||
# Fedora
|
||||
sudo dnf install cava wl-clipboard brightnessctl
|
||||
sudo dnf install cava wl-clipboard brightnessctl qt6-multimedia
|
||||
sudo dnf copr enable wef/cliphist && sudo dnf install cliphist
|
||||
sudo dnf copr enable heus-sueh/packages && sudo dnf install matugen
|
||||
```
|
||||
@@ -315,6 +315,7 @@ sudo sh -c "curl -L https://github.com/AvengeMedia/dgop/releases/latest/download
|
||||
- `cava`: Audio visualizer
|
||||
- `cliphist`: Clipboard history
|
||||
- `gammastep`: Night mode support
|
||||
- `qt6-multimedia`: System sound support
|
||||
|
||||
## Compositor Configuration
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ pragma Singleton
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtMultimedia
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Services.Pipewire
|
||||
@@ -16,6 +15,13 @@ Singleton {
|
||||
readonly property PwNode source: Pipewire.defaultAudioSource
|
||||
|
||||
property bool suppressOSD: true
|
||||
property bool soundsAvailable: false
|
||||
|
||||
property var volumeChangeSound: null
|
||||
property var powerPlugSound: null
|
||||
property var powerUnplugSound: null
|
||||
property var normalNotificationSound: null
|
||||
property var criticalNotificationSound: null
|
||||
|
||||
signal micMuteChanged
|
||||
|
||||
@@ -27,11 +33,106 @@ Singleton {
|
||||
onTriggered: root.suppressOSD = false
|
||||
}
|
||||
|
||||
MediaPlayer {
|
||||
id: volumeChangeSound
|
||||
source: Qt.resolvedUrl("../assets/sounds/freedesktop/audio-volume-change.oga")
|
||||
audioOutput: AudioOutput {
|
||||
volume: 1.0
|
||||
function detectSoundsAvailability() {
|
||||
try {
|
||||
const testObj = Qt.createQmlObject(`
|
||||
import QtQuick
|
||||
import QtMultimedia
|
||||
Item {}
|
||||
`, root, "AudioService.TestComponent")
|
||||
if (testObj) {
|
||||
testObj.destroy()
|
||||
}
|
||||
soundsAvailable = true
|
||||
return true
|
||||
} catch (e) {
|
||||
soundsAvailable = false
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function createSoundPlayers() {
|
||||
if (!soundsAvailable) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
volumeChangeSound = Qt.createQmlObject(`
|
||||
import QtQuick
|
||||
import QtMultimedia
|
||||
MediaPlayer {
|
||||
source: Qt.resolvedUrl("../assets/sounds/freedesktop/audio-volume-change.oga")
|
||||
audioOutput: AudioOutput { volume: 1.0 }
|
||||
}
|
||||
`, root, "AudioService.VolumeChangeSound")
|
||||
|
||||
powerPlugSound = Qt.createQmlObject(`
|
||||
import QtQuick
|
||||
import QtMultimedia
|
||||
MediaPlayer {
|
||||
source: Qt.resolvedUrl("../assets/sounds/plasma/power-plug.ogg")
|
||||
audioOutput: AudioOutput { volume: 1.0 }
|
||||
}
|
||||
`, root, "AudioService.PowerPlugSound")
|
||||
|
||||
powerUnplugSound = Qt.createQmlObject(`
|
||||
import QtQuick
|
||||
import QtMultimedia
|
||||
MediaPlayer {
|
||||
source: Qt.resolvedUrl("../assets/sounds/plasma/power-unplug.ogg")
|
||||
audioOutput: AudioOutput { volume: 1.0 }
|
||||
}
|
||||
`, root, "AudioService.PowerUnplugSound")
|
||||
|
||||
normalNotificationSound = Qt.createQmlObject(`
|
||||
import QtQuick
|
||||
import QtMultimedia
|
||||
MediaPlayer {
|
||||
source: Qt.resolvedUrl("../assets/sounds/freedesktop/message.oga")
|
||||
audioOutput: AudioOutput { volume: 1.0 }
|
||||
}
|
||||
`, root, "AudioService.NormalNotificationSound")
|
||||
|
||||
criticalNotificationSound = Qt.createQmlObject(`
|
||||
import QtQuick
|
||||
import QtMultimedia
|
||||
MediaPlayer {
|
||||
source: Qt.resolvedUrl("../assets/sounds/freedesktop/message-new-instant.oga")
|
||||
audioOutput: AudioOutput { volume: 1.0 }
|
||||
}
|
||||
`, root, "AudioService.CriticalNotificationSound")
|
||||
} catch (e) {
|
||||
console.warn("AudioService: Error creating sound players:", e)
|
||||
}
|
||||
}
|
||||
|
||||
function playVolumeChangeSound() {
|
||||
if (soundsAvailable && volumeChangeSound) {
|
||||
volumeChangeSound.play()
|
||||
}
|
||||
}
|
||||
|
||||
function playPowerPlugSound() {
|
||||
if (soundsAvailable && powerPlugSound) {
|
||||
powerPlugSound.play()
|
||||
}
|
||||
}
|
||||
|
||||
function playPowerUnplugSound() {
|
||||
if (soundsAvailable && powerUnplugSound) {
|
||||
powerUnplugSound.play()
|
||||
}
|
||||
}
|
||||
|
||||
function playNormalNotificationSound() {
|
||||
if (soundsAvailable && normalNotificationSound) {
|
||||
normalNotificationSound.play()
|
||||
}
|
||||
}
|
||||
|
||||
function playCriticalNotificationSound() {
|
||||
if (soundsAvailable && criticalNotificationSound) {
|
||||
criticalNotificationSound.play()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,14 +141,17 @@ Singleton {
|
||||
interval: 50
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
if (SettingsData.soundsEnabled && SettingsData.soundVolumeChanged && !root.suppressOSD) {
|
||||
volumeChangeSound.play()
|
||||
if (!root.suppressOSD && SettingsData.soundsEnabled && SettingsData.soundVolumeChanged) {
|
||||
root.playVolumeChangeSound()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: root.sink?.audio
|
||||
enabled: root.sink?.audio !== null
|
||||
ignoreUnknownSignals: true
|
||||
|
||||
function onVolumeChanged() {
|
||||
volumeSoundDebounce.restart()
|
||||
}
|
||||
@@ -240,4 +344,13 @@ Singleton {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (!detectSoundsAvailability()) {
|
||||
console.warn("AudioService: QtMultimedia not available - sound effects disabled")
|
||||
} else {
|
||||
console.log("AudioService: Sound effects enabled")
|
||||
createSoundPlayers()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ pragma Singleton
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtMultimedia
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Services.UPower
|
||||
@@ -23,22 +22,6 @@ Singleton {
|
||||
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: {
|
||||
@@ -62,9 +45,9 @@ Singleton {
|
||||
|
||||
if (SettingsData.soundsEnabled && SettingsData.soundPluggedIn) {
|
||||
if (isPluggedIn && !previousPluggedState) {
|
||||
powerPlugSound.play()
|
||||
AudioService.playPowerPlugSound()
|
||||
} else if (!isPluggedIn && previousPluggedState) {
|
||||
powerUnplugSound.play()
|
||||
AudioService.playPowerUnplugSound()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ pragma Singleton
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtMultimedia
|
||||
import Quickshell
|
||||
import Quickshell.Services.Notifications
|
||||
import Quickshell.Widgets
|
||||
@@ -199,22 +198,6 @@ 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
|
||||
|
||||
@@ -244,9 +227,9 @@ Singleton {
|
||||
|
||||
if (SettingsData.soundsEnabled && SettingsData.soundNewNotification) {
|
||||
if (notif.urgency === NotificationUrgency.Critical) {
|
||||
criticalNotificationSound.play()
|
||||
AudioService.playCriticalNotificationSound()
|
||||
} else {
|
||||
normalNotificationSound.play()
|
||||
AudioService.playNormalNotificationSound()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user