I am using the following to check if any program is writing to pulseaudio sinks:
This works great straight off of a terminal. This gives me this output:
1 sink input(s) available. index: 4 driver: <protocol-native.c> flags: START_CORKED state: RUNNING sink: 0 <alsa_output.pci-0000_00_1b.0.analog-stereo> volume: front-left: 24144 / 37% / -26.02 dB, front-right: 24144 / 37% / -26.02 dB balance 0.00 muted: no current latency: 59.33 ms requested latency: 25.00 ms sample spec: float32le 2ch 48000Hz channel map: front-left,front-right Stereo resample method: copy module: 7 client: 3 <Firefox> properties: media.name = "AudioStream" application.name = "Firefox" native-protocol.peer = "UNIX socket client" native-protocol.version = "30" application.process.id = "1241" application.process.user = "balajeerc" application.process.host = "smallguy" application.process.binary = "firefox" application.language = "en_IN" window.x11.display = ":0" application.process.machine_id = "82f34b545d7441ad9439148d54b19c2e" application.process.session_id = "c2" application.icon_name = "firefox" module-stream-restore.id = "sink-input-by-application-name:Firefox"
However, when I run this as part of a cron job, it gives me nothing (empty string) even when audio is playing.
Why would this be the case?
EDIT: In response to some of the comments below, I tried a couple more things. I am now running it with full path and logging error using:
/usr/bin/pacmd list-sink-inputs >> $LOG_FILE 2>&1
This throws up the following log which is essentially what is printed to stderr since stdout as I mentioned before is empty:
No PulseAudio daemon running, or not running as session daemon.
My crontab entry is as follows:
*/2 * * * * /home/balajeerc/.i3/utils/idle_check_suspend.sh
This is a user crontab entry, not root.
idle_check_suspend.sh is the script where my pacmd call is.
Kernel version: 4.8.0-49-generic Ubuntu 16.04 pacmd 8.0 Compiled with libpulse 8.0.0 Linked with libpulse 8.0.0