Frewacom / pywalfox

Dynamic theming of Firefox (and Thunderbird) using your Pywal colors
https://addons.mozilla.org/en-US/firefox/addon/pywalfox/
Mozilla Public License 2.0
582 stars 12 forks source link

Could not read colors from colors.json on Windows. #114

Closed Gremious closed 1 year ago

Gremious commented 1 year ago

I am running pywalfox on Windows 11, and it connects ok (Debugger panel says Connected version 2.7). I try to fetch pywal colors, I get:

ERROR:Could not read colors from: `C:\Users\Username\.cache\wal\colors.json`

Said files exists:

{
    "wallpaper": "C:\Users\Username\wallpaper.jpg",
    "alpha": "100",

    "special": {
        "background": "#161321",
        "foreground": "#c4c4c7",
        "cursor": "#c4c4c7"
    },
    "colors": {
        "color0": "#161321",
        // -- snip --
    }
}

C:\Users\Username\.pywalfox\pywalfox.json is also real.

Only error in console i see is

Failed to update option state, target is undefined/null [settings.bundle.js:16:9634](moz-extension://4a79e08f-2b89-4e64-9f1d-91df84665e58/dist/settings.bundle.js)
    Mt moz-extension://4a79e08f-2b89-4e64-9f1d-91df84665e58/dist/settings.bundle.js:16
    zt moz-extension://4a79e08f-2b89-4e64-9f1d-91df84665e58/dist/settings.bundle.js:16
    Jt moz-extension://4a79e08f-2b89-4e64-9f1d-91df84665e58/dist/settings.bundle.js:16
    Jt moz-extension://4a79e08f-2b89-4e64-9f1d-91df84665e58/dist/settings.bundle.js:16
    Jt moz-extension://4a79e08f-2b89-4e64-9f1d-91df84665e58/dist/settings.bundle.js:16

pywalfox log just says failed to read colors.

I am honestly not sure what could be causing this. Is this a known issue, or is there maybe a more verbose way to log?

Gremious commented 1 year ago

This was a ""bug"" in pywalfox-native. Changing to slightly more useful logging errors a la:

    except IOError as io_err:
        error_message = 'Could not read colors from: %s' % PYWAL_COLORS_PATH
        logging.error(error_message)
        logging.error('val error: %s' % io_err)
        return (False, None, error_message)
    except ValueError as val_err:
        error_message = 'Could not read colors from: %s' % PYWAL_COLORS_PATH
        logging.error(error_message)
        logging.error('val error: %s' % val_err)
        return (False, None, error_message)

in fetcher.py (highly recommend) I get:

ERROR:val error: Invalid \escape: line 2 column 21 (char 22)

pywalfox-native died because wal apparently has a bug where it output the wallpaper path, line 2 in my colors.json, with \ slashes, as Windows paths are. That is however, invalid json, since \ is an escape string.

"wallpaper": "C:\\Users\\Gremious\\wallpaper.jpg" in the json works perfectly.

Supposedly wal fixed this https://github.com/dylanaraps/pywal/pull/617 and current impl should return forward slashes so I am extra confused?

I will go look at pywal settings or maybe run a script with it to correct that I guess.

Gremious commented 1 year ago

Solved: Doing pip install pywal gives wal 3.3.0. Current master branch is wal 3.3.1 however. Clone pywal and do pip install . to get the fixes.