Re: Problem pulseaudio
On Tue, Aug 01, 2017 at 08:30:57AM +0200, MENGUAL Jean-Philippe wrote:
> My purpose is to run mplayer in a crontab. My line:
> 00 00 * * * mplayer file
But your *Subject* header says "Problem pulseaudio". I presume this
means you are using pulseaudio.
When you invoke mplayer from cron, it does not have any of the
environment variables that your desktop session sets. No DISPLAY
or XAUTHORITY to talk to the X server, no TERM to define which
set of terminal escape sequences to use (and no controlling terminal
in the first place), and -- relevant to you -- no pulseaudio environment
> If I run mplayer in CLI, everything is good. If cron does it, no sound.
> And log is: Audio becomes stuck!
Probably because in the absence of the pulseaudio variables, mplayer
cannot talk to your pulseaudio daemon.
If it were *me*, I would simply remove pulseaudio and stop attempting
to use it. But you probably run some kind of Desktop Environment which
relies on it, so I'm guessing that's not an option for you.
The second idea that comes to mind would be for you to dump your desktop
session's environment variables to a file upon login, and then source
that file from a bash script invoked by cron when you want to run mplayer.
The problem with this is, I have no idea when or how the pulseaudio
environment variables get set (since I don't use it). Thus, I don't
know where to put the command to dump the variables to a file.
But assuming you can figure that out, create the following *bash script*
and put it somewhere:
declare -px > ~/.cache/env-variables
At login, arrange for it to run from *wherever* it's supposed to run
from. That's the part I can't guess. Happy hunting.
Then from cron, call a second *bash script* that runs this:
Do not put these commands directly inside crontab, because those commands
run under sh, not bash.