dunst icon indicating copy to clipboard operation
dunst copied to clipboard

Using Dunst with Gnome-Shell

Open omentic opened this issue 4 years ago • 15 comments

I recently switched to GNOME from a more modular desktop system, and was wondering if it's possible to replace Gnome-Shell's integrated (and non-customizable) notification system with Dunst. I've looked around online and couldn't find anything suggesting that it is or that it isn't, so I figured this would be the best place to ask.

The org.freedesktop.Notifications interface is unfortunately grabbed by gnome-shell itself, so killing that process and launching Dunst isn't exactly viable. Would there be a way to get Dunst to grab that interface before gnome-shell starts up?

Installation info

  • Version: 1.5.0
  • Install type: package
  • Distro and version: Arch Linux 5.11, GNOME 40

omentic avatar Apr 27 '21 05:04 omentic

You should be able to override the dbus service from GNOME by copying /usr/share/dbus-1/services/org.knopwob.dunst.service to ~/.local/share/dbus-1/services/org.freedesktop.Notifications.service. But if GNOME starts their notification daemon before a notification is sent, then I'm not sure if that will work. EDIT: It's also explained in https://dunst-project.org/faq/#how-to-switch-back-to-notify-osd. If that doesn't work, I would take a look at gnome's dbus service and see what it does.

fwsmit avatar Apr 28 '21 09:04 fwsmit

Unfortunately, that doesn't work. Symlinking dunst to /usr/share/dbus-1/services/org.gnome.Shell.Notifications.service also did nothing. From what I've heard, Gnome-Shell starts early enough that it's always available and programs don't need to find it in the dbus service list (not what I thought that directory did at all).

Do you know if there's a way to force dunst to start and try and claim the Notification service super early?

omentic avatar Apr 28 '21 23:04 omentic

Does gnome even have a file in the services directory. If so can you post its contents here? Other than that I can't think of anything. You might have more luck asking someone who's familiar with gnomes internals. The arch forum is often very helpful

fwsmit avatar Apr 29 '21 08:04 fwsmit

It has one seemingly relevant one: /usr/share/dbus-1/services/org.gnome.Shell.Notifications.service, which contains the following:

[D-BUS Service]
Name=org.gnome.Shell.Notifications
Exec=/usr/bin/gjs /usr/share/gnome-shell/org.gnome.Shell.Notifications

Asking on the Arch forums is a great idea, thanks. I'll report back here for posterity if I find an answer.

omentic avatar Apr 29 '21 09:04 omentic

Asking on the Arch forums is a great idea, thanks. I'll report back here for posterity if I find an answer.

Any updates? I'm having this issue as well

exbotanical avatar Oct 24 '21 16:10 exbotanical

No luck so far. I was going to look more into how notifications are sent - I've "fixed" GNOME not letting you change terminal emulators by symlinking the terminal of my choice to /usr/bin/gnome-terminal, but this seems a little more complex...

omentic avatar Oct 24 '21 19:10 omentic

Coming late to the party. Stumbled upon this issue trying to do the same thing in RHEL 8 (Gnome 3.32.2). I've managed to have dunst working with gnome-shell.

Since gnome-shell registers org.freedesktop.Notifications with no possibility to disable nor replace it, i launch dunst right after the X session starts (I.e. before calling gnome-session that calls gnome-shell) by placing a file in /etc/profile.d/dunst.csh .

if ( ${?DISPLAY} && ${?XAUTHORITY} && ${SHLVL} == '1' ) then
	/usr/bin/dunst &
endif

Yes, I'm using a C-shell, don't judge me ;-)

Here I make sure that a $DISPLAY exists (Xorg) and that I have a X cookie in $XAUTHORITY at my disposal to run dunst. $SHLVL is here to make sure that I'm in the early stage within the X session setup.

Very ugly I must admit, but it works !

coolix avatar Jun 02 '23 09:06 coolix

The workaround works for me on Ubuntu 22.04. I use bash; I put this in /etc/profile.d/dunst.sh, and it seems to be working:

if [ -n "$DISPLAY" ] && [ -n "$XAUTHORITY" ] && [ "$SHLVL" == "1" ]
then
        /usr/bin/dunst &
fi

confluence avatar Apr 09 '24 13:04 confluence