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

Problem Parsing some GTK Themes #183

Open
Julian-Cremer-92 opened this issue Oct 7, 2022 · 2 comments
Open

Problem Parsing some GTK Themes #183

Julian-Cremer-92 opened this issue Oct 7, 2022 · 2 comments

Comments

@Julian-Cremer-92
Copy link

There is sometimes the Problem, HEX colors cannot be parsed by jgmenu-gtktheme.py.
Here my personal quick fix for the issue. However, the foreground color seems to still have problems.

from re import search

def rgb2hex(line):
    """ check if string is in rgb format otherwise treat as hex """
    if search("rgb", line):
        """ convert rgb values to a 6-digit hex string """
        s = line.split("rgb(")
        rgb = s[-1].replace(");", "").split(",")
        r = hex(int(rgb[0]))[2:]
        g = hex(int(rgb[1]))[2:]
        b = hex(int(rgb[2]))[2:]
        return "{}{}{}".format(fmt(r), fmt(g), fmt(b))
    else:
        return line.replace("#", "")

Hope, the code block in the comment helps.

@purpleleaf
Copy link

With Dracula gtk theme the fix doesn't work

Traceback (most recent call last):
  File "/usr/lib/jgmenu/jgmenu-gtktheme.py", line 111, in <module>
    main()
  File "/usr/lib/jgmenu/jgmenu-gtktheme.py", line 94, in main
    setconfig("color_sel_bg", rgb2hex(line))
                              ^^^^^^^^^^^^^
  File "/usr/lib/jgmenu/jgmenu-gtktheme.py", line 41, in rgb2hex
    r = hex(int(rgb[0]))[2:]
            ^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '@define-color theme_selected_bg_color rgba(189'

@johanmalm
Copy link
Collaborator

That python script needs to be improved 😄

This is a much better version: https://github.com/labwc/labwc-gtktheme

Feel free to update it if you want / are able to. If not I'll have a go when I get a spare moment.

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

3 participants