13

Notifications doesn't work on Linux standalone window managers (Openbox, Awesome WM and alike). I tried to install notification-daemon and dunst, but sending with notify-send "something" does not make any window to pop-up.

I tried to run polkit-gnome-agent and run directly notification daemons, but it does not help (while ago I solved similar problem in this way, but now it does nothing).

There is no any indications of errors unless I send trivial notification with python, then I get only vague error message: File "/usr/lib/python3.3/site-packages/gi/types.py", line 113, in function return info.invoke(*args, **kwargs) gi._glib.GError: Could not connect: Connection refused Trivial C program outputs nothing (no error for example).

I'm using Archlinux with systemd and d-bus, I suspect it's a problem with polkit or some kind daemon not runing on window manager start, but have no idea, what could I try or how could I get more meaningfull error messages.

EDIT: I took sample code from there: https://wiki.archlinux.org/index.php/Libnotify#Python

Dbus should be runing because systemd has it as dependency. I have libnotify installed - it is package which provides notify-send. Also notification daemon should start as needed (only when notification arives), by following desktop file /usr/share/dbus-1/services/org.freedesktop.Notifications.service :

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

I had even tried to run daemons directly (just execute) and tried sending notifications. If somenone knows how I could get me more info, please do not hesitate to suggest.

EDIT 2: I tried running notification daemon with sudo: sudo notification-daemon_name & (in my case sudo dunst &) and sudo notify-send something, then notification works. But when I try to do any of the previous actions as unprivileged user (which is important most programs send notification as unprivileged users), nothing shows.

notification-daemon refuses to work at all without any error or warning.

EDIT 3: Clearly it is permissions problem: I can't send notifications without root access. After clean reboot: sudo notify-send "something" works even without manually launching any daemons, however what I (and my launched programs) should do to be able send notifications without root privilegies as it is possible in Gnome or any other full desktop environments?

  • 1
    What does "tried to install notification-daemon" mean? Did you install libnotify as this provides the notify-send command (which is all you need)? – jasonwryan Aug 31 '13 at 21:06
  • You've given far too little information to properly answer this question. Based on the only error message you gave, I suspect that DBus is not running and thus there is nothing for notify-send to connect to. If you gave your "trivial notification" code and the exact error, we might be able to get closer to an answer. – msw Sep 1 '13 at 2:59
  • I took sample codes from there: wiki.archlinux.org/index.php/Libnotify#Python – IBr Sep 1 '13 at 5:15
  • I had success with Dunst. No more "Connection refused" messages. – sshow Oct 11 '16 at 9:04
6

Finally I solved problem myself.

I will leave instructions what I did.

The problem consists of two parts:

  1. Dbus cannot be accessed from within windows manager
  2. Notification daemon cannot get messages from dbus

1st problem solution:

Real problem was, that my windows manager was run from lxdm, which for some reason does not merges config files from /etc/X11/xinit/xinitrc.d except for lxde session (in LXDE dbus works, in awesome wm doesn't). In this folder exists file named 30-dbus with following content:

#!/bin/bash

# launches a session dbus instance
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && type dbus-launch >/dev/null; then
  eval $(dbus-launch --sh-syntax --exit-with-session)
fi

This part of the code defines $DBUS_SESSION_BUS_ADDRESS variable which defines a dbus port to use for various applications. echo $DBUS_SESSION_BUS_ADDRESS can be used as simple sanity check to see if dbus session exists (it should return dbus session file).

Config files from this folder can be merged with simple shell script on session start(code taken from .xinitrc):

#!/bin/bash

if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi

2nd problem solution:

While dbus running and is available to other programs it still needs more access for notifications to work properly, so I needed to run polkit agent, because Awesome WM does not have one. I had chosen lxpolkit, because I already had almost full lxde environment. In my case, just added to my ~/.config/awesome/rc.lua file: awful.util.spawn_with_shell("dex /etc/xdg/autostart/lxpolkit.desktop") , for some reason without this line it refused to start by default with lxdm.

I think gnome polkit agent should work fine too.

  • 1
    note: your display manager does not and should not do anything with .xinitrc/I forget what the other flavor is called. those files are equivalent (which one is used varies by distro) and are only used when you invoke startx or xinit from the console. probably the reason that the system file gets loaded is because it happens in LXDE, not LXDM. – strugee Sep 5 '13 at 2:56
  • Thanks for clarification. It seems that I need to do aditional config loading myself. – IBr Sep 5 '13 at 3:50
  • yes, how you should do that depends on desktop environment/wm. – strugee Sep 5 '13 at 4:13
  • typically all you would do in .xinitrc is start any background daemons that would not be enabled later (you'd do this if you didn't have e.g. gnome-session doing it for you), then at the very last line, exec whatever WM/desktop environment you use. – strugee Sep 5 '13 at 4:15
0

This is not an answer, just a big clarification to maybe help generate the next question.

Thanks for adding the extra detail. You probably do have a permissions problem, but unfortunately it is likely in the permissions needed to connect to the DBus Unix domain socket.

To confirm this run as non-root:

$ strace -o /tmp/ns.out notify-send "why will this not connect"
$ grep '^connect' /tmp/ns.out
connect(4, {sa_family=AF_FILE, path=@"/tmp/dbus-6AIOJVWzCC"}, 23) = 0

except you'll probably get something like

connect(…) = -1 ECONNREFUSED  (Connection refused)

Why? I have no idea. I do know that the notification subsystem has gotten far more attention in the GNOME development community than I ever thought such a superficially simple feature should. I'd suspect some configuration file in the zillion or so GTK configuration locations, but I know that's not too helpful.

  • Indeed I got connect(4, {sa_family=AF_LOCAL, sun_path=@"/tmp/dbus-WC3XySChb5"}, 23) = -1 ECONNREFUSED (Connection refused) connect(4, {sa_family=AF_LOCAL, sun_path=@"/tmp/dbus-b3oei13hP2"}, 23) = -1 ECONNREFUSED (Connection refused) – IBr Sep 2 '13 at 6:32
0

For me it worked to install notify-osd and dunst on i3wm.

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.