Lawrence-Chiappelli / screendimmer

Screen dimming software developed for Arch Linux.
https://aur.archlinux.org/packages/screendimmer/
MIT License
13 stars 0 forks source link

/etc config permissions error #5

Closed mxmilkiib closed 1 year ago

mxmilkiib commented 2 years ago

Started happening yesterday or so

Exception caught initializing the UI:
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/screendimmer/tray.py", line 32, in __init__
    self.init_ui()
  File "/usr/lib/python3.10/site-packages/screendimmer/tray.py", line 42, in init_ui
    self._apply_properties()
  File "/usr/lib/python3.10/site-packages/screendimmer/tray.py", line 205, in _apply_properties
    self._switch_brightness_func(index_repr)()  # Apply last brightness
  File "/usr/lib/python3.10/site-packages/screendimmer/tray.py", line 375, in _hundred
    self.stage_brightness(1.0)
  File "/usr/lib/python3.10/site-packages/screendimmer/tray.py", line 99, in stage_brightness
    configutil.save_changes()
  File "/usr/lib/python3.10/site-packages/screendimmer/configutil.py", line 61, in save_changes
    with open(ini_config, 'w') as new_changes:
PermissionError: [Errno 13] Permission denied: '/etc/screendimmer/brightness.ini'
Lawrence-Chiappelli commented 1 year ago

Thanks for reporting this bug.

For anyone experiencing this, a quick fix would be to apply write permissions to that file: sudo chmod u+w /etc/screendimmer/brightness.ini

That should be a minimal enough change.

If that doesn't work, just go overkill with permissions: sudo chmod a+rwx /etc/screendimmer/brightness.ini && sudo chown $USER /etc/screendimmer/brightness.ini

That said - I only have guesses for the cause. When users install the screendimmer package from the AUR, that file should install with read and write permissions for the user - unless something happened in transit. If it happened out of the blue, something (maybe an OS update or a dependency update) forcefully changed the permissions of that file.

Feel free to open a new issue if you or someone else experience this in the upcoming update.

mxmilkiib commented 1 year ago

It looks like from a fresh install that g+w is needed for the etc conf.

mxmilkiib commented 1 year ago

I think I reinstalled, and got the same error again, so I did

21:47:05 milk@red:~ 2m46s 134 % sudo chmod u+w /etc/screendimmer/brightness.ini
21:47:08 milk@red:~ % screendimmer

Welcome!
Checking system resources... (Current working directory: /home/milk)
✓ - Brightness file path:   brightness.ini @ /etc/screendimmer/brightness.ini
✓ - Desktop file:   screendimmer.desktop @ /usr/share/applications/screendimmer.desktop
✓ - Icon file:      screendimmer.png @ /usr/share/pixmaps/screendimmer.png
Done! Right-click the tray icon to adjust brightness.
Please see 'About' or 'Donate / Support' buttons for more info.

Brightness level: 0.7 -> Applied to eDP-1 -> Applied to DP-1-1

Exception caught initializing the UI:
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/screendimmer/tray.py", line 32, in __init__
    self.init_ui()
  File "/usr/lib/python3.11/site-packages/screendimmer/tray.py", line 42, in init_ui
    self._apply_properties()
  File "/usr/lib/python3.11/site-packages/screendimmer/tray.py", line 205, in _apply_properties
    self._switch_brightness_func(index_repr)()  # Apply last brightness
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/screendimmer/tray.py", line 366, in _seventy
    self.stage_brightness(0.7)
  File "/usr/lib/python3.11/site-packages/screendimmer/tray.py", line 99, in stage_brightness
    configutil.save_changes()
  File "/usr/lib/python3.11/site-packages/screendimmer/configutil.py", line 61, in save_changes
    with open(ini_config, 'w') as new_changes:
         ^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/etc/screendimmer/brightness.ini'

Please try re-installing or reporting this issue upstream at:
https://github.com/Lawrence-Chiappelli/screendimmer/issues                                    
21:48:26 milk@red:~ 130 % sudo chmod a+w /etc/screendimmer/brightness.ini
21:48:30 milk@red:~ % ll /etc/screendimmer/brightness.ini 
4.0K -rw-rw-rw- 1 root root 26 Jul 14 21:44 /etc/screendimmer/brightness.ini
21:48:39 milk@red:~ 130 % screendimmer

Welcome!
Checking system resources... (Current working directory: /home/milk)
✓ - Brightness file path:   brightness.ini @ /etc/screendimmer/brightness.ini
✓ - Desktop file:   screendimmer.desktop @ /usr/share/applications/screendimmer.desktop
✓ - Icon file:      screendimmer.png @ /usr/share/pixmaps/screendimmer.png
Done! Right-click the tray icon to adjust brightness.
Please see 'About' or 'Donate / Support' buttons for more info.

Brightness level: 0.7 -> Applied to eDP-1 -> Applied to DP-1-1

So I'm not sure what's happening there, my user is in root group. Just thought I'd note it here.