So I was having a permissions problem earlier and was going through different methods to try and solve it. Ultimately I solved the issue, but now the buttons in my Kivy app no longer work when pressed on the touchscreen when I run the app with 'sudo python'. If I run the app with just 'python' the buttons work as normal. I suspect that I fudged up some permissions or ownership somewhere along the line that is not giving root all of the necessary things it needs to make kivy buttons work.

I used chown -R pi /home/pi & chmod -R u+rwX /home/pi earlier and I thought this may be a problem so I tried chown -R root /home/pi, but it didn't make a difference. I couldn't even import the kivy module without adding a line in /etc/sudoers:

Defaults    env_keep += "PYTHONPATH" 

The app runs when using sudo, just no button functionality. Is there a way to fix this without having to reinstall everything?

Thanks for your time!

  • I ended up reinstalling everything, but I have the same issue. Not sure how I was able to run sudo python before, but I need it inorder to access a file when running my app.
    – Finksterr
    Jan 27, 2016 at 15:58
  • "I suspect that I fudged up some permissions or ownership somewhere along the line that is not giving root all of the necessary things" - um, root doesn't need permission to do things - that is why that account is called the superuser one. What can keep even someone with those powers out of things is either encryption keys or "cookies" that they don't possess (the latter is sometimes used by the X system to protect X data between client {application} and server {screen}). Perhaps the touch-screen is locked to the pi user by the XServer and inaccessible to the sudoed python prog!
    – SlySven
    Jan 28, 2016 at 3:04
  • Yes, you're right about root. I read that you shouldn't use 'sudo' because the touch screen uses 'probesysfs' when configuring Kivy to use the touch screen as an input source. So, I guess it is not possible to open access restricted files from within a Kivy app?
    – Finksterr
    Jan 28, 2016 at 13:04

1 Answer 1


The user zeeMonkeez supplied an answer to my problem. What he said is this:

I'd suggest a different approach: make


writable to the user running the Python script (most likely pi). Temporarily, this can be done with

sudo chmod a+w /sys/class/backlight/rpi_backlight/bl_power

(this grants write rights to all users). But this will also be reset at the next restart. The solution for that is to write a udev rule. They live in


and on my system, 99-com.rules was a good starting point. Here is what I have in a file called 98-backlight.rules:

SUBSYSTEM=="backlight", PROGRAM="/bin/sh -c 'chown -R root:video /sys/class/backlight && chmod -R 770 /sys/class/backlight; chown -R root:video /sys/devices/platform/rpi_backlight && chmod -R 770 /sys/devices/platform/rpi_backlight'"

This changes the owner group to video and grants group write rights. User pi is by default member of video. Then all you need is a restart (or sudo udevadm control --reload-rules followed by sudo udevadm trigger) to activate the new rule.

  • You can set ownership(OWNER, GROUP) and mode(MODE) with udev rules directly, so there's no need for a PROGRAM statement.
    – bryn
    Jan 3, 2019 at 22:59

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.