i need a python script to run
python
import time
import json
HID_DEVICE_PATH = "dev/hidg0"
def send_keys(keys):
report =[0x00,0x00, keys,0x00,0x00,0x00]
with open (HID_DEVICE_PATH, 'wb') as fd:
fd.write(bytearray(report))
time.sleep(0.01)
fd.write(bytearray[0x00] * 8)
def main():
f = open("keys.json")
data = json.load(f)
for i in data:
send_keys(i)
f.close()
if __name__ == "__name__":
main()
when i plug it into a usb socket. currently i have usb-gadget setup, in /etc/systemd/system/usb-gadget.service i have the script
[Unit]
Description=Run Python script on USB gadget connection
After=network.target
[Service]
ExecStart=/usr/bin/python3 /admin/home/start_keys.py
WorkingDirectory=/admin/home
StandardOutput=inherit
StandardError=inherit
Restart=always
User=admin
[Install]
WantedBy=multi-user.target
which i found and modified for my own use, the python script returns no errors,
but i keep getting the error