From 33e655becdc228f2e47ca6b534872d73ba8b7001 Mon Sep 17 00:00:00 2001 From: purian23 Date: Wed, 3 Dec 2025 09:49:34 -0500 Subject: [PATCH] Add DMS dbus notification service file --- .github/workflows/release.yml | 4 ++ Makefile | 20 ++++-- .../org.freedesktop.Notifications.service | 4 ++ assets/systemd/dms.service | 1 + distro/debian/dms-git/debian/rules | 1 + distro/debian/dms/debian/rules | 1 + distro/fedora/dms.spec | 6 +- distro/opensuse/dms-git.spec | 2 + distro/opensuse/dms.spec | 2 + distro/ubuntu/dms-git/debian/rules | 4 ++ distro/ubuntu/dms/debian/rules | 4 ++ quickshell/Services/NotificationService.qml | 67 +++++++++++++++++++ 12 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 assets/dbus/org.freedesktop.Notifications.service diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2632536b..2792fafd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -599,6 +599,9 @@ jobs: install -Dm644 assets/systemd/dms.service %{buildroot}%{_userunitdir}/dms.service + # Install DBus service activation file + install -Dm644 assets/dbus/org.freedesktop.Notifications.service %{buildroot}%{_datadir}/dbus-1/services/org.freedesktop.Notifications.service + install -Dm644 assets/dms-open.desktop %{buildroot}%{_datadir}/applications/dms-open.desktop install -Dm644 assets/danklogo.svg %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/danklogo.svg @@ -628,6 +631,7 @@ jobs: %doc README.md CONTRIBUTING.md %{_datadir}/quickshell/dms/ %{_userunitdir}/dms.service + %{_datadir}/dbus-1/services/org.freedesktop.Notifications.service %{_datadir}/applications/dms-open.desktop %{_datadir}/icons/hicolor/scalable/apps/danklogo.svg diff --git a/Makefile b/Makefile index d58763b9..aceb3d05 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ SHELL_INSTALL_DIR=$(DATA_DIR)/quickshell/dms ASSETS_DIR=assets APPLICATIONS_DIR=$(DATA_DIR)/applications -.PHONY: all build clean install install-bin install-shell install-completions install-systemd install-icon install-desktop uninstall uninstall-bin uninstall-shell uninstall-completions uninstall-systemd uninstall-icon uninstall-desktop help +.PHONY: all build clean install install-bin install-shell install-completions install-systemd install-dbus install-icon install-desktop uninstall uninstall-bin uninstall-shell uninstall-completions uninstall-systemd uninstall-dbus uninstall-icon uninstall-desktop help all: build @@ -65,6 +65,11 @@ install-systemd: @if [ -n "$(SUDO_USER)" ]; then chown $(SUDO_USER):$(SUDO_USER) $(SYSTEMD_USER_DIR)/dms.service; fi @echo "Systemd service installed to $(SYSTEMD_USER_DIR)/dms.service" +install-dbus: + @echo "Installing DBus service activation file..." + @install -D -m 644 $(ASSETS_DIR)/dbus/org.freedesktop.Notifications.service $(DATA_DIR)/dbus-1/services/org.freedesktop.Notifications.service + @echo "DBus service installed" + install-icon: @echo "Installing icon..." @install -D -m 644 $(ASSETS_DIR)/danklogo.svg $(ICON_DIR)/danklogo.svg @@ -77,11 +82,11 @@ install-desktop: @update-desktop-database -q $(APPLICATIONS_DIR) 2>/dev/null || true @echo "Desktop entry installed" -install: build install-bin install-shell install-completions install-systemd install-icon install-desktop +install: build install-bin install-shell install-completions install-systemd install-dbus install-icon install-desktop @echo "" @echo "Installation complete!" @echo "" - @echo "=== The DMS Team! ===" + @echo "=== Cheers, the DMS Team! ===" # Uninstallation targets uninstall-bin: @@ -107,6 +112,11 @@ uninstall-systemd: @echo "Systemd service removed" @echo "Note: Stop/disable service manually if running: systemctl --user stop dms" +uninstall-dbus: + @echo "Removing DBus service activation file..." + @rm -f $(DATA_DIR)/dbus-1/services/org.freedesktop.Notifications.service + @echo "DBus service removed" + uninstall-icon: @echo "Removing icon..." @rm -f $(ICON_DIR)/danklogo.svg @@ -119,7 +129,7 @@ uninstall-desktop: @update-desktop-database -q $(APPLICATIONS_DIR) 2>/dev/null || true @echo "Desktop entry removed" -uninstall: uninstall-systemd uninstall-desktop uninstall-icon uninstall-completions uninstall-shell uninstall-bin +uninstall: uninstall-systemd uninstall-dbus uninstall-desktop uninstall-icon uninstall-completions uninstall-shell uninstall-bin @echo "" @echo "Uninstallation complete!" @@ -138,6 +148,7 @@ help: @echo " install-shell - Install only shell files" @echo " install-completions - Install only shell completions" @echo " install-systemd - Install only systemd service" + @echo " install-dbus - Install only DBus service activation file" @echo " install-icon - Install only icon" @echo " install-desktop - Install only desktop entry" @echo "" @@ -147,6 +158,7 @@ help: @echo " uninstall-shell - Remove only shell files" @echo " uninstall-completions - Remove only shell completions" @echo " uninstall-systemd - Remove only systemd service" + @echo " uninstall-dbus - Remove only DBus service activation file" @echo " uninstall-icon - Remove only icon" @echo " uninstall-desktop - Remove only desktop entry" @echo "" diff --git a/assets/dbus/org.freedesktop.Notifications.service b/assets/dbus/org.freedesktop.Notifications.service new file mode 100644 index 00000000..78cb12d7 --- /dev/null +++ b/assets/dbus/org.freedesktop.Notifications.service @@ -0,0 +1,4 @@ +[D-BUS Service] +Name=org.freedesktop.Notifications +Exec=/usr/bin/dms run --session +SystemdService=dms.service diff --git a/assets/systemd/dms.service b/assets/systemd/dms.service index f1577276..e6096ce3 100644 --- a/assets/systemd/dms.service +++ b/assets/systemd/dms.service @@ -6,6 +6,7 @@ Requisite=graphical-session.target [Service] Type=simple +BusName=org.freedesktop.Notifications ExecStart=/usr/bin/dms run --session ExecReload=/usr/bin/pkill -USR1 -x dms Restart=always diff --git a/distro/debian/dms-git/debian/rules b/distro/debian/dms-git/debian/rules index de00f6f7..45d8421b 100755 --- a/distro/debian/dms-git/debian/rules +++ b/distro/debian/dms-git/debian/rules @@ -59,6 +59,7 @@ override_dh_auto_install: if [ -d quickshell ]; then \ cp -r quickshell/* debian/dms-git/usr/share/quickshell/dms/; \ install -Dm644 assets/systemd/dms.service debian/dms-git/usr/lib/systemd/user/dms.service; \ + install -Dm644 assets/dbus/org.freedesktop.Notifications.service debian/dms-git/usr/share/dbus-1/services/org.freedesktop.Notifications.service; \ install -Dm644 assets/dms-open.desktop debian/dms-git/usr/share/applications/dms-open.desktop; \ install -Dm644 assets/danklogo.svg debian/dms-git/usr/share/icons/hicolor/scalable/apps/danklogo.svg; \ else \ diff --git a/distro/debian/dms/debian/rules b/distro/debian/dms/debian/rules index e3a82862..9f1d800f 100755 --- a/distro/debian/dms/debian/rules +++ b/distro/debian/dms/debian/rules @@ -56,6 +56,7 @@ override_dh_auto_install: if [ -d DankMaterialShell-$(UPSTREAM_VERSION) ]; then \ cp -r DankMaterialShell-$(UPSTREAM_VERSION)/quickshell/* debian/dms/usr/share/quickshell/dms/; \ install -Dm644 DankMaterialShell-$(UPSTREAM_VERSION)/assets/systemd/dms.service debian/dms/usr/lib/systemd/user/dms.service; \ + install -Dm644 DankMaterialShell-$(UPSTREAM_VERSION)/assets/dbus/org.freedesktop.Notifications.service debian/dms/usr/share/dbus-1/services/org.freedesktop.Notifications.service; \ install -Dm644 DankMaterialShell-$(UPSTREAM_VERSION)/assets/dms-open.desktop debian/dms/usr/share/applications/dms-open.desktop; \ install -Dm644 DankMaterialShell-$(UPSTREAM_VERSION)/assets/danklogo.svg debian/dms/usr/share/icons/hicolor/scalable/apps/danklogo.svg; \ else \ diff --git a/distro/fedora/dms.spec b/distro/fedora/dms.spec index 977d08c0..c61c3c13 100644 --- a/distro/fedora/dms.spec +++ b/distro/fedora/dms.spec @@ -132,17 +132,16 @@ core/bin/${DMS_BINARY} completion fish > %{buildroot}%{_datadir}/fish/vendor_com # Install dgop binary install -Dm755 %{_builddir}/dgop %{buildroot}%{_bindir}/dgop -# Install systemd user service +# Install systemd & dbus user service install -Dm644 assets/systemd/dms.service %{buildroot}%{_userunitdir}/dms.service +install -Dm644 assets/dbus/org.freedesktop.Notifications.service %{buildroot}%{_datadir}/dbus-1/services/org.freedesktop.Notifications.service install -Dm644 assets/dms-open.desktop %{buildroot}%{_datadir}/applications/dms-open.desktop install -Dm644 assets/danklogo.svg %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/danklogo.svg -# Install shell files to shared data location install -dm755 %{buildroot}%{_datadir}/quickshell/dms cp -r quickshell/* %{buildroot}%{_datadir}/quickshell/dms/ -# Remove build files rm -rf %{buildroot}%{_datadir}/quickshell/dms/.git* rm -f %{buildroot}%{_datadir}/quickshell/dms/.gitignore rm -rf %{buildroot}%{_datadir}/quickshell/dms/.github @@ -163,6 +162,7 @@ fi %doc quickshell/README.md %{_datadir}/quickshell/dms/ %{_userunitdir}/dms.service +%{_datadir}/dbus-1/services/org.freedesktop.Notifications.service %{_datadir}/applications/dms-open.desktop %{_datadir}/icons/hicolor/scalable/apps/danklogo.svg diff --git a/distro/opensuse/dms-git.spec b/distro/opensuse/dms-git.spec index ddf43a08..6f64c983 100644 --- a/distro/opensuse/dms-git.spec +++ b/distro/opensuse/dms-git.spec @@ -90,6 +90,7 @@ install -d %{buildroot}%{_datadir}/fish/vendor_completions.d ./dms completion fish > %{buildroot}%{_datadir}/fish/vendor_completions.d/dms.fish || : install -Dm644 assets/systemd/dms.service %{buildroot}%{_userunitdir}/dms.service +install -Dm644 assets/dbus/org.freedesktop.Notifications.service %{buildroot}%{_datadir}/dbus-1/services/org.freedesktop.Notifications.service install -Dm644 assets/dms-open.desktop %{buildroot}%{_datadir}/applications/dms-open.desktop install -Dm644 assets/danklogo.svg %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/danklogo.svg @@ -130,6 +131,7 @@ fi %dir %{_datadir}/quickshell %{_datadir}/quickshell/dms/ %{_userunitdir}/dms.service +%{_datadir}/dbus-1/services/org.freedesktop.Notifications.service %{_datadir}/applications/dms-open.desktop %dir %{_datadir}/icons/hicolor %dir %{_datadir}/icons/hicolor/scalable diff --git a/distro/opensuse/dms.spec b/distro/opensuse/dms.spec index fed79972..5bc817c5 100644 --- a/distro/opensuse/dms.spec +++ b/distro/opensuse/dms.spec @@ -64,6 +64,7 @@ install -d %{buildroot}%{_datadir}/fish/vendor_completions.d ./dms completion fish > %{buildroot}%{_datadir}/fish/vendor_completions.d/dms.fish || : install -Dm644 assets/systemd/dms.service %{buildroot}%{_userunitdir}/dms.service +install -Dm644 assets/dbus/org.freedesktop.Notifications.service %{buildroot}%{_datadir}/dbus-1/services/org.freedesktop.Notifications.service install -Dm644 assets/dms-open.desktop %{buildroot}%{_datadir}/applications/dms-open.desktop install -Dm644 assets/danklogo.svg %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/danklogo.svg @@ -100,6 +101,7 @@ fi %dir %{_datadir}/quickshell %{_datadir}/quickshell/dms/ %{_userunitdir}/dms.service +%{_datadir}/dbus-1/services/org.freedesktop.Notifications.service %{_datadir}/applications/dms-open.desktop %dir %{_datadir}/icons/hicolor %dir %{_datadir}/icons/hicolor/scalable diff --git a/distro/ubuntu/dms-git/debian/rules b/distro/ubuntu/dms-git/debian/rules index 2171d5c4..25f56713 100755 --- a/distro/ubuntu/dms-git/debian/rules +++ b/distro/ubuntu/dms-git/debian/rules @@ -56,6 +56,10 @@ override_dh_auto_install: install -Dm644 dms-git-repo/assets/systemd/dms.service \ debian/dms-git/usr/lib/systemd/user/dms.service + # Install DBus service activation file + install -Dm644 dms-git-repo/assets/dbus/org.freedesktop.Notifications.service \ + debian/dms-git/usr/share/dbus-1/services/org.freedesktop.Notifications.service + # Install desktop file and icon install -Dm644 dms-git-repo/assets/dms-open.desktop \ debian/dms-git/usr/share/applications/dms-open.desktop diff --git a/distro/ubuntu/dms/debian/rules b/distro/ubuntu/dms/debian/rules index b3ddc510..5c088898 100755 --- a/distro/ubuntu/dms/debian/rules +++ b/distro/ubuntu/dms/debian/rules @@ -48,6 +48,10 @@ override_dh_auto_install: install -Dm644 DankMaterialShell-$(BASE_VERSION)/assets/systemd/dms.service \ debian/dms/usr/lib/systemd/user/dms.service + # Install DBus service activation file + install -Dm644 DankMaterialShell-$(BASE_VERSION)/assets/dbus/org.freedesktop.Notifications.service \ + debian/dms/usr/share/dbus-1/services/org.freedesktop.Notifications.service + # Install desktop file and icon install -Dm644 DankMaterialShell-$(BASE_VERSION)/assets/dms-open.desktop \ debian/dms/usr/share/applications/dms-open.desktop diff --git a/quickshell/Services/NotificationService.qml b/quickshell/Services/NotificationService.qml index b6e82b2c..18ce66ce 100644 --- a/quickshell/Services/NotificationService.qml +++ b/quickshell/Services/NotificationService.qml @@ -3,6 +3,7 @@ pragma ComponentBehavior: Bound import QtQuick import Quickshell +import Quickshell.Io import Quickshell.Services.Notifications import qs.Common import "../Common/markdown2html.js" as Markdown2Html @@ -253,6 +254,72 @@ Singleton { } } + // Conflict detection for competing notification daemons + Timer { + id: conflictCheckTimer + interval: 3000 + running: true + repeat: false + onTriggered: { + checkForCompetingDaemons.running = true; + } + } + + Process { + id: checkForCompetingDaemons + command: ["sh", "-c", "pgrep -x 'mako|dunst|deadd-notification-center|swaync' || true"] + running: false + + onExited: (exitCode, exitStatus) => { + if (stdout.trim() !== "") { + const pids = stdout.trim().split('\n'); + console.warn("DMS: Detected competing notification daemon(s) running (PIDs: " + pids.join(", ") + ")"); + console.warn("DMS: Attempting to terminate competing daemons..."); + + killCompetingDaemons.running = true; + } + } + } + + Process { + id: killCompetingDaemons + command: ["sh", "-c", "pkill -x 'mako|dunst|deadd-notification-center|swaync' 2>/dev/null || true"] + running: false + + onExited: (exitCode, exitStatus) => { + console.log("DMS: Attempted to terminate competing notification daemons"); + Qt.callLater(() => { + verifyDaemonsKilled.running = true; + }); + } + } + + Process { + id: verifyDaemonsKilled + command: ["sh", "-c", "pgrep -x 'mako|dunst|deadd-notification-center|swaync' || true"] + running: false + + onExited: (exitCode, exitStatus) => { + if (stdout.trim() !== "") { + const pids = stdout.trim().split('\n'); + const pidList = pids.join(", "); + console.error("DMS: Failed to terminate competing notification daemons (PIDs: " + pidList + ")"); + console.error("DMS: Notifications may not work correctly."); + console.error("DMS: To fix, run: systemctl --user mask mako.service dunst.service"); + + // Show user-visible alert via ToastService + ToastService.showWarning( + "Notification Conflict Detected", + "Another notification daemon (mako/dunst) is running. DMS attempted to stop it but failed.", + "systemctl --user mask mako.service dunst.service", + "notification-conflict" + ); + } else { + console.log("DMS: Successfully claimed notification service"); + } + } + } + component NotifWrapper: QtObject { id: wrapper