Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shutdown-press-simple.py not working #11

Closed
itofficeeu opened this issue Jan 28, 2023 · 0 comments
Closed

shutdown-press-simple.py not working #11

itofficeeu opened this issue Jan 28, 2023 · 0 comments

Comments

@itofficeeu
Copy link

itofficeeu commented Jan 28, 2023

I have installed according to instructions, but the Raspberry does not shut down after pressing the button.

Tried to shorten the button pins. No reaction.

shutdown-press-simple.py
Raspberry Pi 3+
2022-09-22-raspios-bullseye-armhf-lite

~ $ ls -l
total 4
-rwxr-xr-x 1 root root 121 Jan 28 11:15 shutdown-press-simple.py

pi@aqua:~ $ python shutdown-press-simple.py
Failed to set wall message, ignoring: Interactive authentication required.
Failed to power off system via logind: Interactive authentication required.
Failed to open initctl fifo: Permission denied
Failed to talk to init daemon.

What could it be?...

sudo python shutdown-press-simple.py

... did the "trick". - Which tells us it is a permissions problem. Must have created the file with sudo in front.

Just changing to create the script without sudo first, did not solve the problem entirely.

Here what works (for me):

´´´
pi@aqua:~ $ ls -l
total 4
-rwxr-xr-x 1 pi pi 124 Jan 28 13:30 shutdown-press-simple.py
´´´

And for me it needs to have "sudo shotdown now" as command for shutting down.

´´´
#!/usr/bin/env python3

from gpiozero import Button

import os

Button(21).wait_for_press()

os.system("sudo shutdown now")

´´´

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant