Android while true结合while read init.d脚本打开和关闭手机按键灯
我正在尝试制作一个Android while true结合while read init.d脚本打开和关闭手机按键灯,android,init.d,Android,Init.d,我正在尝试制作一个init.d脚本 到目前为止,我已经做到了: while true do if dumpsys input | grep "Last Raw Touch: pointerCount=1"; then echo '1' > /storage/emulated/0/sleepstate else echo '0' > /storage/emulated/0/sleepstate fi done 如果我触摸Android设备的屏幕,文件sleepstate将写入
init.d
脚本
到目前为止,我已经做到了:
while true
do
if dumpsys input | grep "Last Raw Touch: pointerCount=1"; then echo '1' > /storage/emulated/0/sleepstate
else
echo '0' > /storage/emulated/0/sleepstate
fi
done
如果我触摸Android设备的屏幕,文件sleepstate将写入数字1,如果我不触摸屏幕,将写入数字0
这将是文件#1
文件#2
将
while true
do
if "reading the file sleepstate will show '1'"; then
echo '1' > /sys/devices/soc/leds-qpnp-9/leds/button-backlight/brightness
sleep 5
else
If "reading the file sleepstate will show '0'"; then
echo '0' > /sys/devices/soc/leds-qpnp-9/leds/button-backlight/brightness
fi
done
文件#2
的行将打开和关闭我手机的关键灯
在这张图片中,你可以看到我使用的第一个脚本,问题是如果我在第5秒之后触摸屏幕,按键灯会熄灭一秒钟,这可以在我打字时注意到,例如,因为在处理sleep 5时没有进行重新检查
我想做的是触摸触摸屏后,按键灯应打开5秒钟,如果5秒钟未触摸显示屏,按键灯应关闭,对于我在5秒睡眠时间内进行的每次触摸,应重新启动5秒超时,而不是像图片中刚刚处理5秒的脚本那样,如果我在第3秒触摸屏幕,5秒计时器将不会重置
这就是为什么我尝试使用2个文件,希望每次我触摸并将1写入sleepstate文件时,Sleep5计时器和打开按键灯都会再次执行。就这样做吧。您的问题到底是什么?我不知道读取文件2中的1或0的正确命令#我已经在搜索,在读取-r do If时发现了类似的内容,但我不知道确切的行:/