This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shutdown and Power Off Delay
#1
I added a script to the Shut off text in /boot/firmware/config.txt per the process below.  This allows a delay to quietly close OpenCPN and Chromium.  Could this be automated and added to the options in "Raspberry Settings"

Use the Settings app, Raspberry Settings.  Set as below:
 
   
 
After this do the following:
 
  1. Create a new script file:
Code:
sudo nano /usr/local/bin/custom_shutdown.sh
 
  1. 2.  Add the following content to the script:
 
Code:
#!/bin/bash

# Kill Chromium
pkill chromium

# Kill OpenCPN
pkill opencpn

# Wait for applications to close
sleep 5

# Shutdown the system
shutdown -h now

  1. 3. Make the script executable:
 
Code:
sudo chmod +x /usr/local/bin/custom_shutdown.sh

 
  1. 4. Modify the GPIO shutdown configuration to use your custom script. Edit the /boot/firmware/config.txt file:
 
Code:
sudo nano /boot/firmware/config.txt


  1. 5. Find the line that enables GPIO shutdown and modify it to use your custom script:
 
Code:
dtoverlay=gpio-shutdown,gpio_pin=21,active_low=1,gpio_pull=down,gpio_shutdown_command=/usr/local/bin/custom_shutdown.sh
Reply
#2
OpenPlotter is already doing that running this service when a shutdown GPIO is defined in openplotter-settings: https://github.com/openplotter/openplott...hutdown.py

but your approach is very interesting. gpio_shutdown_command is not documented anywhere, where did you get it from?

Add -15 argument to your commands to make sure the configuration files are saved before exiting:

pkill -15 opencpn
Reply
#3
(2025-03-21, 01:11 PM)Sailoog Wrote: OpenPlotter is already doing that running this service when a shutdown GPIO is defined in openplotter-settings: https://github.com/openplotter/openplott...hutdown.py

but your approach is very interesting. gpio_shutdown_command is not documented anywhere, where did you get it from?

Add -15 argument to your commands to make sure the configuration files are saved before exiting:

pkill -15 opencpn

Thanks for the '-15' I will add it, although, it seems like Openplotter has it covered - I didn't know that, I see your solution is only shutting down OCPN, could the feature request be to add more applications?  for me OCPN and Chromium is desirable, but is there a way to safely close all open applications before closing or have check boxes for common ones?

as for "gpio_shutdown_command is not documented anywhere, where did you get it from?" 

it must be somewhere... https://www.perplexity.ai/search/my-rasp...7nok1aA6Tg
Reply
#4
We could add a loop to kill any running process, but that would be too aggressive because we might kill something that needs to run to completion. However, expanding the list of known applications to kill, in addition to OpenCPN, wouldn't hurt. It makes sense to close Chromium and Firefox, anything else?

I will investigate using gpio_shutdown_command for future versions of OP.
Reply
#5
not sure if these have adverse effects if shutdown abruptly but, here are a few I can think of:

SKipper
the Grib viewer
qtVlm
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)