summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guides/setups/notifications.org52
1 files changed, 52 insertions, 0 deletions
diff --git a/guides/setups/notifications.org b/guides/setups/notifications.org
new file mode 100644
index 0000000..5d8ee62
--- /dev/null
+++ b/guides/setups/notifications.org
@@ -0,0 +1,52 @@
+* Fixing dual Plasma/Xfce installations
+Plasma and Xfce both define the ~org.freedesktop.Notifications~ D-BUS
+service. That leads to all kinds of fun ([[https://bugs.kde.org/show_bug.cgi?id=381693][KDE bug]]; [[https://bugzilla.redhat.com/show_bug.cgi?id=484945][Red Hat bug]]); on my
+machine, it causes Plasma sessions to use xfce4-notifyd instead of
+Plasma's own notification mechanism.
+
+[[https://kevinlocke.name/bits/2020/04/12/resolving-desktop-notifications-dbus-service-conflicts/][Kevin Locke]] explains how to solve the issue by defining a third
+~org.freedesktop.Notifications~ service in a higher-priority user
+directory, which runs a command that will determine the current
+desktop environment and start the appropriate notification daemon. In
+~~/.local/share/dbus-1/services/org.freedesktop.Notifications.service~:
+
+#+begin_src conf-desktop
+[D-BUS Service]
+Name=org.freedesktop.Notifications
+Exec=/bin/sh -c "~/.local/lib/meta-notify"
+#+end_src
+
+This gentleman suggests relying on the ~XDG_SESSION_DESKTOP~ variable
+to find out which DE is running; unfortunately, for some reason if I
+log into Plasma first, then into Xfce, this variable (as well as
+~XDG_CURRENT_DESKTOP~ and ~DESKTOP_SESSION~) keeps saying "KDE" when
+the script runs.
+
+(I think this might be caused by Xfce's [[https://gitlab.xfce.org/atomsymbol/xfce4-session/-/blob/xfce4-session-4.14.2/scripts/xinitrc.in.in#L19][xinitrc]] not setting these
+variables if they are not empty, but they *are* set when I look at
+them in a shell once logged in, so… 🤷)
+
+Thus my version of ~~/.local/lib/meta-notify~ falls back on the window
+managers:
+
+#+begin_src sh
+#!/bin/sh
+
+wm=$(wmctrl -m | grep '^Name:' | cut -f2- -d' ')
+
+case ${wm} in
+ KWin)
+ exec /usr/bin/plasma_waitforname org.freedesktop.Notifications
+ ;;
+ Xfwm4)
+ exec dbus-send --session \
+ --dest=org.freedesktop.systemd1 \
+ /org/freedesktop/DBus \
+ org.freedesktop.systemd1.Activator.ActivationRequest \
+ string:xfce4-notifyd.service
+ ;;
+ *)
+ /usr/bin/logger -t $(basename "$0") Unknown window manager \"${wm}\"
+ exit 1
+esac
+#+end_src