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

RaspberryPi 4 - ran the instructions and even the CLI command had error ran with "sudo" #64

Open
Anonymouse83 opened this issue Sep 16, 2024 · 0 comments

Comments

@Anonymouse83
Copy link

My apologies if I am being a numpty...
I wanted to control the backlight on my RaspberryPi 4 running bookworm.
I ran the following in my virtual environment:
pip3 install rpi-backlight
This seemed OK.
I ran the following:-
echo 'SUBSYSTEM=="backlight",RUN+="/bin/chmod 666 /sys/class/backlight/%k/brightness /sys/class/backlight/%k/bl_power"' | sudo tee -a /etc/udev/rules.d/backlight-permissions.rules
There was no error.
From a python3 shell, I ran:

from rpi_backlight import Backlight
backlight = Backlight()

(using copy and paste just in case!)

This produces:-

>>> backlight = Backlight()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/alarmpi/Projects/AlarmClock/alarm/lib/python3.11/site-packages/rpi_backlight/__init__.py", line 82, in __init__
    self._max_brightness = self._get_value("max_brightness")  # 255
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alarmpi/Projects/AlarmClock/alarm/lib/python3.11/site-packages/rpi_backlight/__init__.py", line 99, in _get_value
    raise e
  File "/home/alarmpi/Projects/AlarmClock/alarm/lib/python3.11/site-packages/rpi_backlight/__init__.py", line 91, in _get_value
    return int((self._backlight_sysfs_path / name).read_text())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/pathlib.py", line 1059, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/pathlib.py", line 1045, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/sys/class/backlight/rpi_backlight/max_brightness'

I then exited the Python3 shell, and tried:-

sudo echo 'SUBSYSTEM=="backlight",RUN+="/bin/chmod 666 /sys/class/backlight/%k/brightness /sys/class/backlight/%k/bl_power"' | sudo tee -a /etc/udev/rules.d/backlight-permissions.rules
``
But this had the same result.
I then tried `rpi-backlight --help` which gave the command line options - so the program was installed.
I then tried `rpi-backlight --get-brightness` and got the following:-

rpi-backlight --get-brightness
Traceback (most recent call last):
File "/home/alarmpi/Projects/AlarmClock/alarm/bin/rpi-backlight", line 8, in
sys.exit(main())
^^^^^^
File "/home/alarmpi/Projects/AlarmClock/alarm/lib/python3.11/site-packages/rpi_backlight/cli.py", line 80, in main
backlight = Backlight(
^^^^^^^^^^
File "/home/alarmpi/Projects/AlarmClock/alarm/lib/python3.11/site-packages/rpi_backlight/init.py", line 82, in init
self._max_brightness = self._get_value("max_brightness") # 255
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alarmpi/Projects/AlarmClock/alarm/lib/python3.11/site-packages/rpi_backlight/init.py", line 99, in _get_value
raise e
File "/home/alarmpi/Projects/AlarmClock/alarm/lib/python3.11/site-packages/rpi_backlight/init.py", line 91, in _get_value
return int((self._backlight_sysfs_path / name).read_text())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/pathlib.py", line 1059, in read_text
with self.open(mode='r', encoding=encoding, errors=errors) as f:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/pathlib.py", line 1045, in open
return io.open(self, mode, buffering, encoding, errors, newline)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/sys/class/backlight/rpi_backlight/max_brightness'

I also tried it as sudo, and the error was that the program wasn't found.

Any advice as to what I am doing wrong would be most appreciated.

Many thanks,
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