0

Alright, I've been trying this for several days and I'm just dying here...

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

or

43 09 * * * amixer sset 'Master' 16384

Nothing. Fine. So I make a really simple python script to run.

#!/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 doesn't work. 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 freaking nothing. So, alright, fine, I'll try running it as a sudoer but with the user beforehand. Nothing again.

I am exhausted and this isn't even my full-time job. I'm a librarian. I'm just technically inclined and had done this before with regular raspberry pi 4s. Just no volume because they weren't powerful enough.

Please help me. I just want to adjust the volume automatically without logging into a ssh for every NUC we're putting up.

2
  • 2
    This looks like a simple programming Question - nothing to do with Pi. Raspberry Pi Desktop - is a Linux OS with the Raspbian Look&Feel. Why would you put your undocumented program in a system directory?
    – Milliways
    Commented Oct 9, 2021 at 0:05
  • Maybe try systemd and target something late in the boot process? Commented Oct 9, 2021 at 23:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.