📜  argon one command power button script (1)

📅  最后修改于: 2023-12-03 15:29:27.953000             🧑  作者: Mango

Argon One Command Power Button Script

Argon One is a high-quality aluminum case for Raspberry Pi 4 that comes with a built-in power button script. The power button script allows users to safely shut down and power on their Raspberry Pi 4 with a simple press of a button.

How to Install the Script

The installation process for the Argon One Power Button script is quite easy. Here are the steps:

  1. Clone the GitHub repository by running the following command in the terminal:
git clone https://github.com/Argon40Tech/argon1-powerbutton.git
  1. Navigate to the argon1-powerbutton directory:
cd argon1-powerbutton
  1. Run the installation script:
sudo ./install.sh
  1. Reboot your system:
sudo reboot
  1. Test the power button by pressing it. Your Raspberry Pi 4 should now safely shut down.
How to Modify the Script

You can modify the Argon One Power Button script to suit your needs. Here are some of the modifications you can make:

  • Change the shutdown delay time
  • Change the LED color

To modify the script, navigate to the argon1-powerbutton directory and open the argononed.py file using your preferred text editor. Here's an example of how to change the shutdown delay time:

  1. Find the following lines of code:
# shutdown function
def shutdown():
    global hold_time
    if hold_time >= SHUTDOWN_TIME:
        subprocess.call(['sudo', 'poweroff'])
    else:
        if hold_time == 0:
            os.system("sudo shutdown -c")
        message = "Hold for %d more seconds to shutdown" % (SHUTDOWN_TIME-hold_time)
        blink_led(RED, 0.2, 3)
        logger.info(message)
        print(message)
    hold_time = 0
    os.system("sudo shutdown -c")
  1. Change the value of SHUTDOWN_TIME to your desired delay time. For example, change it to 10 seconds:
SHUTDOWN_TIME = 10
  1. Save the file and restart the script:
sudo systemctl restart argononed.service
Conclusion

The Argon One Power Button script is a convenient tool that allows Raspberry Pi 4 users to safely shut down and power on their system with ease. The installation process is straightforward, and the script can be easily modified to suit your needs. Give it a try and enjoy the benefits!