arbowl / cyberdeck-battery-indicator

A GUI battery indicator for raspberry pi and x728 UPS
1 stars 0 forks source link

Running into a permission issue. #1

Closed RoodyPooCandyButt closed 1 month ago

RoodyPooCandyButt commented 1 month ago

I am getting the following when I check for errors:

pi@test-pi:~ $ cd cyberdeck-battery-indicator
pi@test-pi:~/cyberdeck-battery-indicator $ python3 battery_indicator.py
QStandardPaths: wrong permissions on runtime directory /run/user/1000, 0770 instead of 0700
Traceback (most recent call last):
  File "/home/pi/cyberdeck-battery-indicator/battery_indicator.py", line 162, in <module>
    tray_icon.setIcon(battery_state_icons[9])
                      ~~~~~~~~~~~~~~~~~~~^^^
KeyError: 9

Any idea how to fix it?

arbowl commented 1 month ago

The permission issue is just a warning that can maybe be ignored. I think the true issue is in the code:

    battery_state_icons = {
            0 : QIcon(dir + 'battery_0.png'),
            1 : QIcon(dir + 'battery_1.png'),
            2 : QIcon(dir + 'battery_2.png'),
            3 : QIcon(dir + 'battery_3.png'),
            4 : QIcon(dir + 'battery_4.png'),
            5 : QIcon(dir + 'battery_5.png'),
            6 : QIcon(dir + 'battery_6.png'),
            7 : QIcon(dir + 'battery_7.png'),
            'Charging' : QIcon(dir + 'battery_charging.png'),
            'Warning' :QIcon(dir + 'battery_alert.png')
    }

...

tray_icon.setIcon(battery_state_icons[9])

I haven't looked at this in a while, so I don't quite remember what I was trying to do, but if you sudo nano battery_indicator.py and change tray_icon.setIcon(battery_state_icons[9]) to tray_icon.setIcon(battery_state_icons["Warning"]) (near the bottom of the file), I think it will do what's expected. Let me know if you can test this fix, and if it works, I'll make a comprehensive cleanup to the code with this included 🙂

arbowl commented 1 month ago

Actually, if you don't mind waiting until later today, I went ahead and made some QOL updates. I just need to test it before I push it to main. Sit tight! I'll @ you when it's done.

RoodyPooCandyButt commented 1 month ago

Thanks!

arbowl commented 1 month ago

My RasPi is out of commission tonight unfortunately 😅 the change I proposed above should get this rolling at least. I'll update this eventually, but it might take up to a week, just FYI

arbowl commented 1 month ago

Hey! Thank you for your patience. I was able to get around to fixing this; I tested it on my machine and it works, so hopefully you have the same success. If not, feel free to ping me again with the error message and I'll take a look :)