entropyconquers / Force-RGB-Color-on-M1-M2-Mac-Script

41 stars 1 forks source link

Type Error: list indices must be integer or slices #1

Open benjamindahl opened 1 year ago

benjamindahl commented 1 year ago

MacBook Pro M1 Pro with macOS 12 and Python 3.11.3

Executing the Script I get the following error:

Step 1: File unlocked successfully.
Step 2: File copied successfully.
Step 3: File converted to JSON successfully.
Traceback (most recent call last):
  File "/Users/benny/Documents/GitHub/Force-RGB-Color-on-M1-M2-Mac-Script/edit_json.py", line 12, in <module>
    DisplayConfig = configs['DisplayConfig']
                    ~~~~~~~^^^^^^^^^^^^^^^^^
TypeError: list indices must be integers or slices, not str
Error: Command failed: Running the python script

com.apple.windowserver.displays.plist.zip Plist-File in XML format

robertgrabowski commented 1 year ago

@benjamindahl Same for me. The Python script seems to expect this JSON structure:

    "DisplayAnyUserSets": {
        "Configs": [
            {
               "DisplayConfig": [
                    {
                        "UnmirrorInfo": {
                           "IsLink": false,
                           ...                    
                        },
                        ...

but for me, the structure is actually

    "DisplayAnyUserSets": {
        "Configs": [
            [
                {
                    "UnmirrorInfo": {
                        "IsLink": false,
                        ...
                    },
                    ...

i.e. each item in the Configs list is already a "DisplayConfig", i.e a list of "DisplaySets".

It worked for me after I changed

    DisplayConfig = configs['DisplayConfig']

to just

    DisplayConfig = configs

in line 12 of edit_json.py.