notifications.org (2301B)
1 * Fixing dual Plasma/Xfce installations 2 Plasma and Xfce both define the ~org.freedesktop.Notifications~ D-BUS 3 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 4 machine, it causes Plasma sessions to use xfce4-notifyd instead of 5 Plasma's own notification mechanism. 6 7 [[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 8 ~org.freedesktop.Notifications~ service in a higher-priority user 9 directory, which runs a command that will determine the current 10 desktop environment and start the appropriate notification daemon. In 11 ~~/.local/share/dbus-1/services/org.freedesktop.Notifications.service~: 12 13 #+begin_src conf-desktop 14 [D-BUS Service] 15 Name=org.freedesktop.Notifications 16 Exec=/bin/sh -c "~/.local/lib/meta-notify" 17 #+end_src 18 19 This gentleman suggests relying on the ~XDG_SESSION_DESKTOP~ variable 20 to find out which DE is running; unfortunately, for some reason if I 21 log into Plasma first, then into Xfce, this variable (as well as 22 ~XDG_CURRENT_DESKTOP~ and ~DESKTOP_SESSION~) keeps saying "KDE" when 23 the script runs. 24 25 (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 26 variables if they are not empty, but they *are* set when I look at 27 them in a shell once logged in, so… 🤷) 28 29 Thus my version of ~~/.local/lib/meta-notify~ falls back on the window 30 managers: 31 32 #+begin_src sh 33 #!/bin/sh 34 35 wm=$(wmctrl -m | grep '^Name:' | cut -f2- -d' ') 36 37 case ${wm} in 38 KWin) 39 exec /usr/bin/plasma_waitforname org.freedesktop.Notifications 40 ;; 41 Xfwm4) 42 exec dbus-send --session \ 43 --dest=org.freedesktop.systemd1 \ 44 /org/freedesktop/DBus \ 45 org.freedesktop.systemd1.Activator.ActivationRequest \ 46 string:xfce4-notifyd.service 47 ;; 48 *) 49 /usr/bin/logger -t $(basename "$0") Unknown window manager \"${wm}\" 50 exit 1 51 esac 52 #+end_src