So you want to use a switch button instead of a push button. In that case you can't use dtoverlay=gpio-shutdown, and you have to implement your own script to check the GPIO states. Here is a script that does the same like dtoverlay=gpio-shutdown. Start it from autostart.sh. You have to adapt it for your needs:
Python
#!/usr/bin/python
# This script was authored by AndrewH7 and belongs to him.
# (www.instructables.com/member/AndrewH7)
# You have permission to modify and use this script only for your own personal usage.
# You do not have permission to redistribute this script as your own work.
# Use this script at your own risk.
import sys
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')
import RPi.GPIO as GPIO
import os
# Replace YOUR_CHOSEN_GPIO_NUMBER_HERE with the GPIO pin number you wish to use.
# Make sure you know which rapsberry pi revision you are using first.
# The line should look something like this e.g. "gpio_number = 7".
button_gpio_number = 3
led_gpio_number = 13
# Use BCM pin numbering (i.e. the GPIO number, not pin number).
# WARNING: this will change between Pi versions.
# Check yours first and adjust accordingly.
GPIO.setmode(GPIO.BCM)
# It's very important the pin is an input to avoid short-circuits.
# The pull-up resistor means the pin is high by default.
GPIO.setup(button_gpio_number, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(led_gpio_number, GPIO.OUT)
# Switch LED on.
# LED will switch off automatically at shutdown by using normal GPIO state.
GPIO.output(led_gpio_number, True)
# Use falling edge detection to see if pin is pulled low to avoid repeated polling.
# Send command to system to shutdown.
try:
GPIO.wait_for_edge(button_gpio_number, GPIO.FALLING)
os.system("shutdown -h now")
except:
pass
# Revert all GPIO pins to their normal states (i.e. input = safe).
GPIO.cleanup()
Display More