Denver, this version keeps the lights off when the screen is locked/unlocked like intended.
But I can't keep the lights on. After screen on they are off again.
Did you add chmod commands only to the the lights off script?
Okay, so now the app works as expected when you set the capacitive button backlight brightness to "off". But there is now a new issue where if you set the capacitive button backlight brightness to "on" in the app that the buttons do not turn back on when the screen powers on. Very interesting, and thanks for testing it out.
The workaround that I had implemented in the test version 1 is to chmod 666 the file, write 0 or 255 to the file, then chmod 444 the file. It sounds like I only need to chmod 444 the file if setting the capacitive button brightness to "off". Setting its permissions to 444 when the backlight button setting is "on" actually prevents the backlight from turning back on when the screen turns back on.
I've attached v2 of the test app to this post. In this version, it will only chmod 444 the file when setting the capacitive button backlight brightness to "off"; when setting it to "on" it leaves the permissions as 666. Please test it out and let me know if the setting persists for both "on" and "off" when the screen turns on and off. Thanks!