Shutdown pi with Processing?

Hi Folks,

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.

Thanks!

1 Like

You can do it easily with exec(…), but you need to have password-less sudo set up.

1 Like

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.

2 Likes