I posted this in Raspberry Pi, but was told that it was better suited in a general linux or programming area. So I figured I'd ask here now...
I am putting together a kiosk that should play video. I'm using a NUC with Raspberry Pi Desktop. Everything works but automating the audio with Cron. I work in a school and blasting sound during the day would kind of suck, so I want it to change based on the time of the day.
When run from terminal the following code works:
/usr/bin/amixer set Master 16384
and
amixer sset 'Master' 16384
So, I put it into Cron:
15 09 * * * /usr/bin/amixer set Master 16384
and
43 09 * * * amixer sset 'Master' 16384
Nothing. Fine. So I make a really simple python script to run (yes, I realize I put it in a system folder, I was planning on moving it, it just kind of ended up there.)
#!/usr/bin/env python3
from subprocess import call
call(["/usr/bin/amixer", "set", "Master", "65536"])
I make it executable:
chmod +x /etc/python/sound100.py
Then I call it from the terminal with both:
/etc/python/sound100.py
and
/usr/bin/python3 /etc/python/sound100.py
Again, it works. Yay. Into Cron it goes. Neither:
11 10 * * * python3 /etc/python/sound100.py
nor
11 10 * * * /usr/bin/python3 /etc/python/sound100.py
Not even
11 10 * * * /etc/python/sound100.py
Nothing works.
So begins the actual troubleshooting. I check the syslog. Everything runs, but I learn that when I run it as a sudo command it says that the maximum volume is 83 when run as a sudoer. So that means I can't run it as from sudo crontab -e, but I start running it from the user's cron.
Still nothing. So I try running it as a sudoer but with the user beforehand. Nothing again.
Please help me. I just want to adjust the volume automatically without logging into ssh for every NUC we're putting up three times a day until I quit or retire.
Thank you!