As for the frontlight control, this oldie still works for setting brightness 0-100:
https://www.mobileread.com/forums/sh...d.php?t=200706
As for JavaScript, again have a look at my WebPortal mod, if you can use JavaScript to fire a http request to
http://webportal/cgi-bin/... the WebPortal would run a cgi-bin shell script for you that does the things you want. So you could both disable touchscreen, and change light, whenever you want using JavaScript with cgi-bin helper.