mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
sounds: make qt6-multimedia optional
This commit is contained in:
@@ -1198,6 +1198,7 @@ Item {
|
|||||||
color: Theme.surfaceContainerHigh
|
color: Theme.surfaceContainerHigh
|
||||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
|
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
|
||||||
border.width: 0
|
border.width: 0
|
||||||
|
visible: AudioService.soundsAvailable
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: soundsSection
|
id: soundsSection
|
||||||
|
|||||||
@@ -287,11 +287,11 @@ sudo sh -c "curl -L https://github.com/AvengeMedia/danklinux/releases/latest/dow
|
|||||||
**4.1 Core optional dependencies**
|
**4.1 Core optional dependencies**
|
||||||
```bash
|
```bash
|
||||||
# Arch Linux
|
# 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
|
paru -S matugen-bin dgop
|
||||||
|
|
||||||
# Fedora
|
# 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 wef/cliphist && sudo dnf install cliphist
|
||||||
sudo dnf copr enable heus-sueh/packages && sudo dnf install matugen
|
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
|
- `cava`: Audio visualizer
|
||||||
- `cliphist`: Clipboard history
|
- `cliphist`: Clipboard history
|
||||||
- `gammastep`: Night mode support
|
- `gammastep`: Night mode support
|
||||||
|
- `qt6-multimedia`: System sound support
|
||||||
|
|
||||||
## Compositor Configuration
|
## Compositor Configuration
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ pragma Singleton
|
|||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtMultimedia
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import Quickshell.Services.Pipewire
|
import Quickshell.Services.Pipewire
|
||||||
@@ -16,6 +15,13 @@ Singleton {
|
|||||||
readonly property PwNode source: Pipewire.defaultAudioSource
|
readonly property PwNode source: Pipewire.defaultAudioSource
|
||||||
|
|
||||||
property bool suppressOSD: true
|
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
|
signal micMuteChanged
|
||||||
|
|
||||||
@@ -27,11 +33,106 @@ Singleton {
|
|||||||
onTriggered: root.suppressOSD = false
|
onTriggered: root.suppressOSD = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
MediaPlayer {
|
||||||
id: volumeChangeSound
|
|
||||||
source: Qt.resolvedUrl("../assets/sounds/freedesktop/audio-volume-change.oga")
|
source: Qt.resolvedUrl("../assets/sounds/freedesktop/audio-volume-change.oga")
|
||||||
audioOutput: AudioOutput {
|
audioOutput: AudioOutput { volume: 1.0 }
|
||||||
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
|
interval: 50
|
||||||
repeat: false
|
repeat: false
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (SettingsData.soundsEnabled && SettingsData.soundVolumeChanged && !root.suppressOSD) {
|
if (!root.suppressOSD && SettingsData.soundsEnabled && SettingsData.soundVolumeChanged) {
|
||||||
volumeChangeSound.play()
|
root.playVolumeChangeSound()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: root.sink?.audio
|
target: root.sink?.audio
|
||||||
|
enabled: root.sink?.audio !== null
|
||||||
|
ignoreUnknownSignals: true
|
||||||
|
|
||||||
function onVolumeChanged() {
|
function onVolumeChanged() {
|
||||||
volumeSoundDebounce.restart()
|
volumeSoundDebounce.restart()
|
||||||
}
|
}
|
||||||
@@ -240,4 +344,13 @@ Singleton {
|
|||||||
return result
|
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
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtMultimedia
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import Quickshell.Services.UPower
|
import Quickshell.Services.UPower
|
||||||
@@ -23,22 +22,6 @@ Singleton {
|
|||||||
onTriggered: root.suppressSound = false
|
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 string preferredBatteryOverride: Quickshell.env("DMS_PREFERRED_BATTERY")
|
||||||
|
|
||||||
readonly property UPowerDevice device: {
|
readonly property UPowerDevice device: {
|
||||||
@@ -62,9 +45,9 @@ Singleton {
|
|||||||
|
|
||||||
if (SettingsData.soundsEnabled && SettingsData.soundPluggedIn) {
|
if (SettingsData.soundsEnabled && SettingsData.soundPluggedIn) {
|
||||||
if (isPluggedIn && !previousPluggedState) {
|
if (isPluggedIn && !previousPluggedState) {
|
||||||
powerPlugSound.play()
|
AudioService.playPowerPlugSound()
|
||||||
} else if (!isPluggedIn && previousPluggedState) {
|
} else if (!isPluggedIn && previousPluggedState) {
|
||||||
powerUnplugSound.play()
|
AudioService.playPowerUnplugSound()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ pragma Singleton
|
|||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtMultimedia
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Services.Notifications
|
import Quickshell.Services.Notifications
|
||||||
import Quickshell.Widgets
|
import Quickshell.Widgets
|
||||||
@@ -199,22 +198,6 @@ Singleton {
|
|||||||
property var expandedMessages: ({})
|
property var expandedMessages: ({})
|
||||||
property bool popupsDisabled: false
|
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 {
|
NotificationServer {
|
||||||
id: server
|
id: server
|
||||||
|
|
||||||
@@ -244,9 +227,9 @@ Singleton {
|
|||||||
|
|
||||||
if (SettingsData.soundsEnabled && SettingsData.soundNewNotification) {
|
if (SettingsData.soundsEnabled && SettingsData.soundNewNotification) {
|
||||||
if (notif.urgency === NotificationUrgency.Critical) {
|
if (notif.urgency === NotificationUrgency.Critical) {
|
||||||
criticalNotificationSound.play()
|
AudioService.playCriticalNotificationSound()
|
||||||
} else {
|
} else {
|
||||||
normalNotificationSound.play()
|
AudioService.playNormalNotificationSound()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user