0

I would like to run the following command through crontab:

30 12 * * * natasha /usr/bin/canberra-gtk-play --file="/home/natasha/Audio/Dat_Jene_Tabletki.wav" --volume=15 --loop=3

but this command isn't executed. Run of the corresponding command directly from command line works.

The lines

4 12 * * * natasha /usr/bin/cvlc /home/natasha/Audio/Dat_Jene_Tabletki.wav 55 16 * * * natasha /usr/local/bin/mpg123 -q /home/natasha/Downloads/file.mp3

are executed correctly with crontab, but canberra-gtk-play doesn't work.

Could somebody help me with this, please?

My system is openSUSE 42.1.

Thank you in advance.

Regards, Natalia

1 Answer 1

0

canberra-gtk-play doesn't work from cron because, as its name says, it depends on the GTK+ graphical toolkit – which requires Xorg or another X11 or Wayland server to be accessible.

Cron jobs don't have easy access to X11 because the server's address isn't always the same – you can try setting DISPLAY=":0" and likewise XAUTHORITY=…, but they might be different after a reboot.

In contrast, the PulseAudio sound service's address is always at a fixed location, and on systems which don't use PA it's just a matter of accessing /dev directly.

(If you happen to be running Wayland, then canberra-gtk-play should be able to connect to it, but.)


I would suggest forgetting canberra-gtk-play because... if all you want is to play a sound, why would you even bother with tools which require X11?

A better option would be paplay or mpv or even mplayer.

1
  • Thank you! I have succeeded to do this using paplay. The reason to use canberra-gtk-play was the ability to set volume manually. paplay can do this as well, while looping may be organized with script.
    – natasha
    Mar 4, 2017 at 11:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .