Add homemonitor script

This commit is contained in:
2023-11-12 14:46:51 -07:00
parent 78ae4b92ae
commit 6aa6929574
2 changed files with 30 additions and 0 deletions

20
homemonitor.py Normal file
View File

@@ -0,0 +1,20 @@
# This script monitors Protovac's HOME key to kick the user
# back to the home screen
#
# Runs as root
import os
import serial
ser = serial.Serial('/dev/ttyAMA1', baudrate=9600)
try:
while True:
if ser.read() == b'\x01' and ser.read() == b'N' and ser.read() == b'\r':
print('Home key pressed, killing login process...')
os.system('killall -9 login')
finally:
print('Closing serial port...')
ser.close()