This repo contains two hooks called event2io and io2key:
- event2io listens a message from another process through a pipe and triggers a gpio related function given a config file.
- io2key waits for a gpio pin to be triggered and simulates a keystroke afterwards given a config file.
- io2key.py binds GPIO pins to simulate keystrokes given a config file.
- input_key.yaml config file which maps pins to a keystroke.
- io2key_launcher.sh runs io2key.py after activating a python env.
- event2io.py listens an event through named pipe and accordingly controls GPIO pins given a config file
- output_key.yaml config file which maps pins to different variables that are aimed to trigger different kinds of gpio related functions.
- event2io_launcher.sh runs event2io.py after activating a python env.
- exemple.py shows how to use named pipe in the main code to communicate with event2io.
- logger.py logging singleton script that is used in even2io and io2key. The logs is stored in
/var/log/cel-apus/
Both _launcher.sh activate a specific python env called cel-apus. If you already have another env, do the dedicated path changes and package installations
Starts event2io_launcher that runs its associated hook after activating the env.
To create the service copy the content of services/event2io.service
to /etc/systemd/system/event2io.service
and set the correct permission:
sudo chmod 644 /etc/systemd/system/event2io.service
event2io.service should be owned by root so do the dedicated changes in case with the following:
sudo chown root:root /etc/systemd/system/event2io.service
Starts io2key_launcher that runs its associated hook after activating the env.
To create the service copy the content of services/io2key.service
to /etc/systemd/system/io2key.service
and set the correct permission:
sudo chmod 644 /etc/systemd/system/io2key.service
io2key.service should be owned by root so do the dedicated changes in case with the following:
sudo chown root:root /etc/systemd/system/io2key.service
tmpfile is a systemd service used to create temporary files on boot. In this case, it is used to create log files for both hooks and set them to the correct file permission when the instance starts.
Write the following in /etc/tmpfiles.d/cel-apus.conf
d /var/log/cel-apus 0755 cellari cellari -
Enable both services:
sudo systemctl enable io2key --now
sudo systemctl enable even2io --now
To check the log of a specific service:
journalctl -u <service_name>
To check the log of a specific hook:
watch -n 1 cat /var/log/cel-apus/logs-<hook_name>.log
In case of permission error related to the launchers, check if they are owned by the user and have the correct permissions (744)
io2key works with a library called xdotool that able users to send a kestroke
Xdotool works with x-server thus exporting DISPLAY=0 is needed in the io2key_launcher.sh
If there is still an issue related to the x-server display when trying to enable the service try :
xhost si:localuser:root
sudo apt-get install -y xdotool
pip install Jetson.GPIO
pip install pyyaml
pip install python-dotenv