dunst-project / dunst

Lightweight and customizable notification daemon
https://dunst-project.org
Other
4.65k stars 344 forks source link

Using Dunst with Gnome-Shell #857

Open omentic opened 3 years ago

omentic commented 3 years ago

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

fwsmit commented 3 years ago

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.

omentic commented 3 years ago

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?

fwsmit commented 3 years ago

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

omentic commented 3 years ago

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.

exbotanical commented 3 years ago

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

omentic commented 3 years ago

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...

coolix commented 1 year ago

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 !

confluence commented 7 months ago

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
g1bber1sh commented 6 months ago

how would the above look on wayland, if its even possible on wayland?

stefan2904 commented 4 months ago

On X11 (with i3 on gnome-flashback):

When I try to start dunst manually, I get WARNING: Unknown keyboard shortcut: 'ctrl+grave'", CRITICAL: Cannot acquire 'org.freedesktop.Notifications': Name is acquired by 'Notification Daemon' with PID '6053'.', but after killing that process I can start dunst and it seems to work.

bynect commented 4 months ago

On X11 (with i3 on gnome-flashback):

When I try to start dunst manually, I get WARNING: Unknown keyboard shortcut: 'ctrl+grave'", CRITICAL: Cannot acquire 'org.freedesktop.Notifications': Name is acquired by 'Notification Daemon' with PID '6053'.', but after killing that process I can start dunst and it seems to work.

The first warning is probably due to an old dunstrc. Try copying a more recent one

stefan2904 commented 4 months ago

Sorry for the confusion; the post was not meant as a bug report but instead as a possible workaround for the mentioned issue. ;-)

fwsmit commented 4 months ago

Your workaround will not work with gnome-shell. Gnome runs in a single process. Killing the notification daemon would kill the entire gnome shell. A workaround would be to start dunst before starting gnome-shell. I think some similar workarounds have been mentioned above

omentic commented 4 months ago

(three years later, my workaround has been to switch to KDE :wink:)