mirror of
https://github.com/acatoire/bipbipzizik.git
synced 2026-03-10 08:01:18 +00:00
31 lines
591 B
Python
31 lines
591 B
Python
|
|
|
|
"""
|
|
Create a device file
|
|
"""
|
|
|
|
|
|
import os.path
|
|
from evdev import InputDevice, list_devices
|
|
|
|
DEVICES_LIST = [InputDevice(fn) for fn in list_devices()]
|
|
FILE_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), '/deviceName.txt')
|
|
|
|
|
|
i = 0
|
|
|
|
print("Choose the reader from list")
|
|
|
|
for dev in DEVICES_LIST:
|
|
print(i, dev.name)
|
|
i += 1
|
|
|
|
DEVICE_ID = int(input('Device Number: '))
|
|
|
|
with open(FILE_PATH, 'w') as file_handler:
|
|
file_handler.write(DEVICES_LIST[DEVICE_ID].name)
|
|
# FIXME, doesn't save the file
|
|
file_handler.close()
|
|
|
|
print("Device name saved in: " + FILE_PATH)
|