8

I was testing i3wm (sudo apt-get install i3 is what I ran, and chose i3 from the log in screen) on my machine and after a while, decided to switch back to Unity. Upon switching back, I noticed that notifications came in the top right corner similar to i3 even though I was using Unity.

I'd really like it to use the normal Unity notification bubbles instead.

I looked into it and turns out instead of notify-osd, dunst is being used.

I tried using sudo vim /usr/share/dbus-1/services/org.freedesktop.Notifications.service and editing the file, but it has the correct line (i.e. Exec=/usr/lib/x86_64-linux-gnu/notify-osd) as expected.

I also tried unity-tweak-tool --reset-unity but that didn't do anything.

Is it possible for me to return to the normal notifications? Any help would be greatly appreciated. Thanks :)

Edit: I was able to return to the normal notifications by removing i3wm itself (and dunst). What I am actually asking is: is it possible to change to normal notifications while still keeping i3 and dunst on my system?

Note: This is NOT a duplicate of Notify-osd notifications appear unthemed in top-left corner. The solution there is to remove dunst and I would like to keep dunst and have that work when I choose i3, and have notify-osd work when I choose Unity.

8

I realize I'm two years late to the party, but if anyone else encounters this problem, here's a solution that will use notify-osd when logged into Unity, and dunst when running i3.

If you just want to keep dunst installed, but not auto-invoke it via DBus skip to the Quick Hack section.

Dunst in i3, notify-osd in Unity

Step 1

We want to override the behaviors of /usr/share/dbus-1/services/org.freedesktop.Notifications.service and more importantly /usr/share/dbus-1/services/org.knopwob.dunst.service.

Since Dbus looks at $XDG_DATA_HOME when searching for service files, and Ubuntu for some reason doesn't set that environment variable, we need to do it ourselves:

echo 'export XDG_DATA_HOME=${XDG_DATA_HOME:="$HOME/.local/share"}' >> ~/.profile 

Step 2

We need to create our service file:

mkdir -p $HOME/.local/share/dbus-1/services
nano $HOME/.local/share/dbus-1/services/usernotify.service

Make the file look like this:

[D-BUS Service]
Name=org.freedesktop.Notifications
Exec=/usr/bin/my_notifier

Step 3

Create the script referred to in your D-BUS file that invokes dunst if i3 is running, otherwise notify-osd:

sudo nano /usr/bin/my_notifier

Make it look like this:

#!/bin/bash
set -euo pipefail
if pgrep -x i3 >/dev/null; then
    /usr/bin/dunst
else
    /usr/lib/x86_64-linux-gnu/notify-osd
fi

Make it executable:

sudo chmod a+x /usr/bin/my_notifier

Step 4

That should be it. Log out and then log in again. Test it in both Unity and i3 by running

notify-send foo bar

Quick Hack

If you exclusively want to use notify-osd it's enough to edit /usr/share/dbus-1/services/org.knopwob.dunst.service accordingly:

[D-BUS Service]
Name=org.freedesktop.Notifications
#Exec=/usr/bin/dunst
Exec=/usr/lib/x86_64-linux-gnu/notify-osd
  • 3
    Even at 2 years late, this answer is super helpful :) I have marked it as accepted, since reading the steps, it makes complete sense as to why this should work. Thanks! :) I unfortunately do not switch b/w Unity and i3 anymore, and instead use Gnome and Stumpwm; but still this answer was extremely helpful for learning! :) – Jay Bosamiya Sep 20 '17 at 22:43
  • It is not needed to set XDG_DATA_HOME as the directory "$HOME/.local/share" is used by default, see the spec. It would be better to create the service file in /use/local/share/dbus-1/services/ to affect all users. Still I see something about dunst in journalctl -b0 output, so I wonder, if there is better way to handle this. – jarno Jul 13 '20 at 14:11
0
sudo apt-get purge dunst

That should remove it.

  • Please read the note at the bottom of the question. I would like to keep dunst and have that work when I choose i3, and have notify-osd work when I choose Unity. – Jay Bosamiya Nov 2 '15 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.