问题
I want to make a kivy app for the raspberry pi that can use a touch screen. I was able to get the demos to work with the touchscreen with just "python ~/kivy/examples/demo/showcase/main.py". The issue comes when I need to start the app with "sudo python main.py", the touchscreen then ceases to work.
The app I am trying to write uses the rpi_ws281x library for controlling addressable leds which HAS to be run as root. Is there a way to run the kivy app as root while still enabling the touchscreen functionality?
If there isn't, is there a way to send data from the kivy app to say a script which is running sudo that controls the leds?
I've looked a lot of places but no one seems to have had this problem before (or they could work around it by changing the privileges of other directories where they were accessing the sudo protected content). Any help is greatly appreciated!
回答1:
Well apparently I didn't look hard enough. The solution is to copy "~/.kivy/config.ini" to "/root/.kivy/config.ini"
So the commands are
"sudo cp ~/.kivy/config.ini /root/.kivy/config.ini"
And then everything works happily together!
来源:https://stackoverflow.com/questions/39542539/run-kivy-app-as-root-user-with-touch-screen-on-raspberry-pi