This setup adds a momentary button that requests an orderly Raspberry Pi OS shutdown and can wake a halted Pi while power remains connected. It uses the kernel gpio-shutdown device-tree overlay and systemd-logind; no continuously running Python service is required.
The default wiring uses GPIO3 because Raspberry Pi firmware supports wake from halt when GPIO3 is pulled low.
Use a normally-open, momentary push button: