Skip to content
A tiny script for a Raspberry Pi shutdown restart / shutdown button.
Python
Branch: master
Clone or download
Pull request Compare This branch is 1 commit ahead of scruss:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE.txt
README.md
pipowerbutton.py

README.md

Pi Power Button

A simple combined shutdown / restart button with visual feedback for a Raspberry Pi.

A fork of this script by @scruss, this simple python script allows for a single button to restart or shutdown a Pi depending on how long the button was held. This version adds LED sequences to distinguish between restarting and shutting down. The code structure has also been changed for personal preference, and the systemd service has been dropped for the same reason (although @scruss's service can still easily be used).

See imswebra.com for more information on how I personally use this script.

Defaults

  • Holding the button for 2 to 5 seconds will restart your Pi. The LED will flash quickly to indicate a restart.
  • Holding the button for more than 5 seconds will shutdown your Pi. The LED will slowly blink to indicate a shutdown.
  • The button should be connected to BCM pin 18.
  • The LED should be connected to BCM pin 15.

See the script's inline comments for more information on the user variables.

Installation

Download or clone the script and add python3 /path/to/pipowerbutton.py & to your rc.local file to have the script run on boot.

License

This work is licensed under the MIT license.

You can’t perform that action at this time.