gkaindl / ambi-tv

a flexible ambilight clone for embedded linux
296 stars 85 forks source link

ambi-tv start in background - button doesn't work #22

Open alink75 opened 10 years ago

alink75 commented 10 years ago

Hi,

i have installed ambi-tv and it works very well. Additionally i installed netio (http://netio.davideickhoff.de/) which gives me the possibility to simulate a button on gpio 3 and start and stop the ambi-TV via smartphone. I works well, as long as ambi-tv is started in a normal way. As soon as i start it via rc.local or in the background with "ambi-tv --button-gpio 3" ambi-tv doesn't recognize the pushed button. Even with a hardware button on the pins 5 and 6 it doesn't work when ambi-tv is started in the background.

Do you have any suggestions?

Thank you,

Alex

Mrjohns42 commented 10 years ago

It probably has something to do with users. Netio is probably set up to work with whatever your user account on the pi is. rc.local runs programs as the root user (IIRC)

alexeymohr commented 10 years ago

I had this issue as well, but was able to work around it by setting my Pi to auto-login and then starting the ambi-tv app with the exec command in my /etc/rc.local file.

This page has the info for how to set the Pi to auto-login at startup:

http://www.akeric.com/blog/?p=1976

However, I didn't have any luck following its instructions for running ambi-tv at startup with button functionality. I found a different way to accomplish that. I created a bash script that started Ambi-TV with the parameters that I wanted, and saved it to my home folder as "startambiatboot". I tested the script to make sure it worked when run manually, and the button worked as well.

In order to make this happen automatically at startup, I added this line to /etc/rc.local before the "exit 0" line:

(cd /home/pi && exec ./startambiatboot)

So now if I plug my Pi into a monitor to watch startup, I'll see the Pi automatically log in and come to a standard prompt, and then automatically boot Ambi-TV. At this point the button functions properly. Pretty sweet!