Audtool not working from crontab
Added by Tim L over 9 years ago
I am trying to control Audacious with a cron job. My command line is
*/1 * * * * audtool playback-pause && mplayer /home/tim/Music/chtones/tone.wav && audtool playback-play
The expected result is that Audacious will pause it's current playlist, the tone.wav will play and the Audacious will resume where it left off every minute.
With the command above, I get the following error message, and nothing happens at all...no pause, no tone.wav.
D-Bus error: Cannot autolunch D-Bus without X11 $DISPLAY
So I found some links online in the Ubuntu forums, etc... that suggested adding DISPLAY:=0 to the command, so the command would read
*/1 * * * * DISPLAY:=0 audtool playback-pause && mplayer /home/tim/Music/chtones/tone.wav && DISPLAY:=0 audtool playback-pause
and I have also tried
*/1 * * * * DISPLAY:=0 && audtool playback-pause && mplayer /home/tim/Music/chtones/tone.wav && DISPLAY:=0 && audtool playback-pause
In both cases, the tone file plays but Audacious does not pause.
I am using Lubuntu 14.10
What am I doing wrong?
Replies (7)
RE: Audtool not working from crontab - Added by John Lindgren over 9 years ago
I don't know if this will solve the issue, but you have the colon and equals sign switched; it should be "DISPLAY=:0".
RE: Audtool not working from crontab - Added by Tim L over 9 years ago
Hi John,
When I change it to
DISPLAY=:0 && audtool playback-pause && mplayer /home/tim/Music/chtones/starcallchimes.wav && DISPLAY=:0 && audtool playback-pause
I get the error message
D-Bus error: Cannot autolunch D-Bus without X11 $DISPLAY
and nothing else happens.
RE: Audtool not working from crontab - Added by Tim L over 9 years ago
I have also tried taking the && out between DISPLAY and audtool, and now the tones wave file plays but Audacious still does not pause.
RE: Audtool not working from crontab - Added by John Lindgren over 9 years ago
It looks like you need to have the same DBUS_SESSION_BUS_ADDRESS as in the environment of the running audacious process.
Try running the following before audtool:
export "$(strings /proc/"$(pidof audacious)"/environ | grep DBUS_SESSION_BUS_ADDRESS)"
RE: Audtool not working from crontab - Added by Tim L over 9 years ago
John,
That works perfectly! Thank you so much for your help.
RE: Audtool not working from crontab - Added by Jim Turner over 7 years ago
cron normally runs as ROOT, you might try:
*/1 * * * * sudo su -c "DISPLAY:=0 && audtool playback-pause && mplayer /home/tim/Music/chtones/tone.wav && DISPLAY:=0 && audtool playback-pause" <your-abUser-id>
Regards,
Jim