Last active
April 30, 2024 20:30
-
-
Save straight-shoota/8ce901271a4d80bb88981fac3acb9d09 to your computer and use it in GitHub Desktop.
Photoboy key trigger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/systemd/system/multi-user.target.wants/photobox-trigger.service | |
[Unit] | |
Description=Photobox Trigger Service | |
After=multi-user.target | |
[Service] | |
Type=idle | |
User=pi | |
ExecStart=/usr/bin/python3 /home/pi/photobox/trigger.py | |
Restart=on-failure | |
[Install] | |
WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from evdev import InputDevice, ecodes | |
import sys | |
import os | |
KEYBOARD = "/dev/input/event0" | |
device = InputDevice(KEYBOARD) | |
for event in device.read_loop(): | |
if event.type == ecodes.EV_KEY: | |
if((event.code == ecodes.KEY_PAGEDOWN or event.code == ecodes.KEY_ENTER) and event.value == 0 ): | |
os.system("echo hi") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment