I wrote an udev-rule and a systemd-unit, so if I plugin a particular harddrive rsync backups my /home in background and play a audio file when ready.
During my first attempt I get following error pulseaudio[8802]: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Note this I have fixed. I got my sound back after skript is ready.
But I don't understand why pacat or even aplay needs this variable for playing only audio. I'm runnning ubuntu bionic with xfce4-session.
Both
aplay
andpacat
are userland programs, so the easiest way for the programmer to get the sound out there is to use thedbus
library as no one in their right mind is going to use these incron
, or in audev
rule, or heaven forbid insystemd
, right??? :-)Well, they were right until you came along, and you indeed took the correct solution to solve this issue.
If you would like to be able to make a sound without X running at all (E.G. a headless server), you might echo the
ASCII
BEL
¹ character to atty
.Note 1: 007: really retro: a beep was more important then a Line Feed (10), Form Feed (12) or Carriage Return (13)...