I was just wondering if there was a way to shutdown the raspberry pi using Processing (or a way to have Processing run the ‘sudo shutdown’ command in Terminal).
Use case: Have a GPIO button on pi that when pressed stops the Processing sketch and shuts down the pi.
You can do it easily with exec(…), but you need to have password-less sudo set up.
Depending on your operating system, you can explicitly grant your user passwordless sudo to the shutdown command only, e.g. in /etc/sudoers.d
Much better than leaving your user wide open.