But it's been a long day and I only just remembered that my plan was to go via MDI connection, so the audio on the Pi is irrelevant. \o/
#!/usr/bin/python import sys sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib') import RPi.GPIO as GPIO import time import subprocess # we will use the pin numbering to match the pins on the Pi, instead of the # GPIO pin outs (makes it easier to keep track of things) GPIO.setmode(GPIO.BOARD) # use the same pin that is used for the reset button (one button to rule them all!) GPIO.setup(5, GPIO.IN, pull_up_down = GPIO.PUD_UP) oldButtonState1 = True while True: #grab the current button state buttonState1 = GPIO.input(5) # check to see if button has been pushed if buttonState1 != oldButtonState1 and buttonState1 == False: subprocess.call("echo 1 > /sys/class/backlight/rpi_backlight/bl_power && shutdown -h now", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) oldButtonState1 = buttonState1 time.sleep(.1)Going through the manual again, there's a section of what's passed through the GPIO.
The DAC/AMP might only provide the first 10 pins on top, but it's not clear from photos if they actually prevent you connecting to the other pins underneath?
It seems counter to the point of this to take all pins, only use some, and pass through ones that can't be properly used. What about sending a message to IQaudio seeing if they're willing to help?
Failing that, maybe you can de-solder the connector and replace it with several smaller ones, including a right-angle connector for the unused ports? Or I guess cables would be easier at the expense of compactness.
Heh, so yeah, that's a really simple solution - that loser Xen would have pointed it out ages ago if he were here.
You can use systemd to hook into system events (like shutdown), so you can create simple service like this one with Before=shutdown.target:
[Unit] Description=/etc/rc.local.shutdown Compatibility Before=shutdown.target [Service] ExecStart=/bin/true ExecStop=/etc/rc.local.shutdown RemainAfterExit=yes [Install] WantedBy=multi-user.target
Where /etc/rc.local.shutdown is a script containing the original echo 0 > /sys/class/backlight/rpi_backlight/bl_power (prepended with #!/bin/bash line) and once you've enabled that service, any time the system is shutdown - whether via Kodi or command line or the button - it triggers the script and turns off the backlight.
/storage/.config/shutdown.sh
case "$1" in halt) # your commands here ;; poweroff) # your commands here ;; reboot) # your commands here ;; *) # your commands here ;; esac