Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nasa-gcn/systemd-gpio
Use systemd to configure commands to run when a GPIO button is pressed on a Raspberry Pi. Inspired by https://github.com/ali1234/systemd-gpio.
https://github.com/nasa-gcn/systemd-gpio
gpio gpiozero raspberry-pi systemd
Last synced: about 2 months ago
JSON representation
Use systemd to configure commands to run when a GPIO button is pressed on a Raspberry Pi. Inspired by https://github.com/ali1234/systemd-gpio.
- Host: GitHub
- URL: https://github.com/nasa-gcn/systemd-gpio
- Owner: nasa-gcn
- License: other
- Created: 2023-12-28T22:22:33.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-18T15:03:37.000Z (12 months ago)
- Last Synced: 2024-03-27T00:54:30.254Z (9 months ago)
- Topics: gpio, gpiozero, raspberry-pi, systemd
- Language: Python
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
SYSTEMD-GPIO(5)
===============NAME
----
systemd-gpio - run commands when a button on a GPIO pin is pressedDESCRIPTION
-----------Use systemd to configure commands to run when a button attached to a GPIO pin is pressed, released, or held.
To configure a GPIO pin, create a file called /etc/gpio/*N*, where *N* is an integer pin number following the `gpiozero pin numbering`_ convention. Once you have populated the configuration file, activate the button by running the following command, replacing *N* with the pin number::
sudo systemctl enable --now [email protected]
ENVIRONMENT
-----------| GPIO_PULL_UP
| GPIO_ACTIVE_STATE
| GPIO_BOUNCE_TIME
| GPIO_HOLD_TIME
| GPIO_HOLD_REPEATButton behavior. See the documentation for the corresponding constructor arguments of `gpiozero.Button`_.
| GPIO_WHEN_HELD
| GPIO_WHEN_PRESSED
| GPIO_WHEN_RELEASEDCommands to run when the button is held, pressed, or released, respectively. See the documentation for the corresponding properties of `gpiozero.Button`_.
FILES
-----/etc/gpio/*N*
Configuration file for GPIO pin *N*, where *N* corresponds to the `gpiozero pin numbering`_. The file should be in the `systemd EnvironmentFile syntax`_ and may define any of the environment variables listed above.
HISTORY
-------This project is inspired by https://github.com/ali1234/systemd-gpio. The main difference is that we are using gpiozero_ rather than WiringPi_, because WiringPi is no longer maintained.
EXAMPLES
--------The following example configures GPIO 23 so that when it is pressed, it prints a message to all TTYs, and when held, shuts down the machine::
# /etc/gpio/23
GPIO_HOLD_TIME=5
GPIO_WHEN_PRESSED="wall 'Hold the power button for 5 seconds to power off.'"
GPIO_WHEN_HELD=poweroffTo activate the pin, run the following command::
sudo systemctl enable --now [email protected]
.. _gpiozero: https://github.com/gpiozero/gpiozero
.. _WiringPi: https://web.archive.org/web/20220405225008/http://wiringpi.com/wiringpi-deprecated/
.. _`gpiozero.Button`: https://gpiozero.readthedocs.io/en/latest/api_input.html#gpiozero.Button
.. _`gpiozero pin numbering`: https://gpiozero.readthedocs.io/en/latest/recipes.html#pin-numbering
.. _`systemd EnvironmentFile syntax`: https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#EnvironmentFile=SEE ALSO
--------systemctl(1), systemd.exec(5)