Looks like removing the two following lines from my script made it work again:
export DISPLAY=:0
export XAUTHORITY=/home/user/.Xauthority
Strange, I found these in a discussion in a forum where some people had
the same problem as mine...
** Changed in: pulseaudio (Ubuntu)
Status: New => Invalid
--
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to pulseaudio in Ubuntu.
https://bugs.launchpad.net/bugs/1575118
Title:
"AO: [pulse] Init failed: Connection refused" with mplayer from cron
Status in pulseaudio package in Ubuntu:
Invalid
Bug description:
Arrrrrrggggggg.... This is driving me crazzzzzyyyy....
Not sure this is the right place, but I can't find why pa refuses to
play my sound!!!!
I'm trying to play a sound every hour, so I added the following line to my
/etc/crontab:
0 */1 * * * user /home/user/Softs/alarm.sh
My alarm.sh script is:
#!/usr/bin/env bash
export DISPLAY=:0
export XAUTHORITY=/home/user/.Xauthority
/usr/bin/mplayer -ao pulse -vo null /home/user/.sounds/alarm_clock_short.ogg
When I redirect the output of mplayer, I get:
AO: [pulse] Init failed: Connection refused
Failed to initialize audio driver 'pulse'
I don't understand why, since cron is supposed to run the command as
"user".
I've tried millions of things:
$ env -i
$ /home/user/Softs/alarm.sh
=> works
$ env -i
$ sh
$ /home/user/Softs/alarm.sh
=> works
$ env -i
$ . /home/user/Softs/alarm.sh
=> works
$ env -i
$ sh
$ . /home/user/Softs/alarm.sh
=> works
$ env -i
$ sh
$ su user -c '/usr/bin/paplay /home/user/.sounds/alarm_clock_short.ogg
=> asks for passwd, but works
I've also changed the last line of my alarm.sh script with:
/usr/bin/paplay /home/user/.sounds/alarm_clock_short.ogg
or:
su gmuller -c '/usr/bin/paplay /home/user/.sounds/alarm_clock_short.ogg'
I get the (same) error:
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
Is the problem with my knowledge of pulseaudio, with pulseaudio's
right management, or am I just crazily stupid?
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1575118/+subscriptions
--
Mailing list: https://launchpad.net/~touch-packages
Post to : [email protected]
Unsubscribe : https://launchpad.net/~touch-packages
More help : https://help.launchpad.net/ListHelp