import sys import time with open('/dev/hidg0', 'wb') as f: f.write(b'\x01') time.sleep(0.3) f.write(b'\x00') sys.exit()