themix-project / themix-plugin-base16

Plugin for import/export to Themix/Oomox and a static mirror of Base16 project themes (https://github.com/chriskempson/base16)
1 stars 0 forks source link

CLI erros when generating themes #7

Closed jas2394 closed 11 months ago

jas2394 commented 11 months ago

I'm not able to generate the themes from CLI, GUI is working fine. Here is the exact command i ran:

themix-base16-cli /opt/oomox/plugins/base16/templates/rofi/templates/config.yaml /home/jas/.cache/wal/colors-oomox

I Got following output:

Import Colors From Image plugin: `colorz` library is not installed - less color-import options are available.
Import Colors From Image plugin: `colorthief` library is not installed - less color-import options are available.
Import Colors From Image plugin: `haishoku` library is not installed - less color-import options are available.
Import Colors From Image plugin: not all optional libraries are installed (see above).
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/opt/oomox/plugins/base16/cli.py", line 41, in <module>
    main()
  File "/opt/oomox/plugins/base16/cli.py", line 34, in main
    base16_theme = convert_oomox_to_base16(colorscheme=themix_theme)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/oomox/plugins/base16/oomox_plugin.py", line 108, in convert_oomox_to_base16
    if get_lightness(base16_theme["base01"]) > get_lightness(base16_theme["base00"]):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/oomox/plugins/base16/../../oomox_gui/terminal.py", line 205, in get_lightness
    return sum(int_list_from_hex(theme_color))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/oomox/plugins/base16/../../oomox_gui/color.py", line 36, in int_list_from_hex
    result = [hex_to_int(c) for c in color_list_from_hex(color_text)]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/oomox/plugins/base16/../../oomox_gui/color.py", line 36, in <listcomp>
    result = [hex_to_int(c) for c in color_list_from_hex(color_text)]
              ^^^^^^^^^^^^^
  File "/opt/oomox/plugins/base16/../../oomox_gui/color.py", line 24, in hex_to_int
    return int(f"0x{text}", 0)
           ^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 0: '0xNo'

I tried running Gui from terminal to see the logs when generating base16 theme from my pywal colors here is the output:

themix-gui 
Import Colors From Image plugin: `colorz` library is not installed - less color-import options are available.
Import Colors From Image plugin: `colorthief` library is not installed - less color-import options are available.
Import Colors From Image plugin: `haishoku` library is not installed - less color-import options are available.
Import Colors From Image plugin: not all optional libraries are installed (see above).

(__main__.py:20668): Gtk-WARNING **: 11:55:11.044: Attempting to add a widget with type GtkBox to a container of type GtkBox, but the widget is already inside a container of type GtkBox, please remove the widget from its existing container first.
ERROR: can't convert `scheme-name=oomox-testing_cli` from Base16 to template :(
ERROR: can't convert `scheme-author=oomox-testing_cli` from Base16 to template :(
ERROR: can't convert `scheme-slug=oomox-testing_cli` from Base16 to template :(
ERROR: can't convert `themix_GTK3_GENERATE_DARK=True` from Base16 to template :(
ERROR: can't convert `themix_SURUPLUS_GRADIENT_ENABLED=True` from Base16 to template :(
ERROR: can't convert `themix_ROUNDNESS=5` from Base16 to template :(
ERROR: can't convert `themix_SPACING=3` from Base16 to template :(
ERROR: can't convert `themix_GRADIENT=0.0` from Base16 to template :(
ERROR: can't convert `themix__PIL_PALETTE_QUALITY=100` from Base16 to template :(
ERROR: can't convert `themix__PIL_PALETTE_STYLE=basic` from Base16 to template :(
ERROR: can't convert `themix__PIL_PALETTE_STRICT=False` from Base16 to template :(
ERROR: can't convert `themix__PIL_PALETTE_INVERSE=False` from Base16 to template :(
ERROR: can't convert `themix__PIL_THEME_TEMPLATE=1` from Base16 to template :(
ERROR: can't convert `themix__PIL_IMAGE_PREVIEW=None` from Base16 to template :(
ERROR: can't convert `themix_BASE16_GENERATE_DARK=False` from Base16 to template :(
ERROR: can't convert `themix_BASE16_INVERT_TERMINAL=False` from Base16 to template :(
ERROR: can't convert `themix_BASE16_MILD_TERMINAL=False` from Base16 to template :(
ERROR: can't convert `themix_THEME_STYLE=oomox` from Base16 to template :(
ERROR: can't convert `themix_CARET_SIZE=0.04` from Base16 to template :(
ERROR: can't convert `themix_OUTLINE_WIDTH=1` from Base16 to template :(
ERROR: can't convert `themix_BTN_OUTLINE_WIDTH=1` from Base16 to template :(
ERROR: can't convert `themix_BTN_OUTLINE_OFFSET=-3` from Base16 to template :(
ERROR: can't convert `themix_CINNAMON_OPACITY=1.0` from Base16 to template :(
ERROR: can't convert `themix_UNITY_DEFAULT_LAUNCHER_STYLE=False` from Base16 to template :(
ERROR: can't convert `themix_ICONS_STYLE=gnome_colors` from Base16 to template :(
ERROR: can't convert `themix_ICONS_NUMIX_STYLE=0` from Base16 to template :(
ERROR: can't convert `themix_TERMINAL_THEME_MODE=auto` from Base16 to template :(
ERROR: can't convert `themix_TERMINAL_BASE_TEMPLATE=monovedek` from Base16 to template :(
ERROR: can't convert `themix_TERMINAL_THEME_AUTO_BGFG=True` from Base16 to template :(
ERROR: can't convert `themix_TERMINAL_THEME_EXTEND_PALETTE=False` from Base16 to template :(
ERROR: can't convert `themix_TERMINAL_THEME_ACCURACY=128` from Base16 to template :(

I can genrate themes from gui but i need cli for my scripts. I tired to see the issue by reading the files: oomox_plugin.py and cli.py

but i can't able to find any things.

Plus i want to know where does the geenrated theme will be exported as in GUI there is option to speicfy the path but the cli.py only accepts 2 arguments which are templates and color, no argumet for destinaiton.

Thanks for this project. If you need any clarification and somethjing that i missed to include let me know.

jas2394 commented 11 months ago

After digging more i found this:

I can generate colors with cli if i specify the schemes. Here is the output:

❯ themix-base16-cli /opt/oomox/plugins/base16/templates/rofi/templates/default.mustache /opt/oomox/plugins/base16/schemes/icy/icy.yaml 
Import Colors From Image plugin: `colorz` library is not installed - less color-import options are available.
Import Colors From Image plugin: `colorthief` library is not installed - less color-import options are available.
Import Colors From Image plugin: `haishoku` library is not installed - less color-import options are available.
Import Colors From Image plugin: not all optional libraries are installed (see above).
ERROR: can't convert `scheme-name=themix_base16` from Base16 to template :(
ERROR: can't convert `scheme-author=themix_base16` from Base16 to template :(
ERROR: can't convert `scheme-slug=themix_base16` from Base16 to template :(
ERROR: can't convert `themix_TERMINAL_THEME_MODE=manual` from Base16 to template :(
ERROR: can't convert `themix__PIL_PALETTE_QUALITY=100` from Base16 to template :(
ERROR: can't convert `themix__PIL_PALETTE_STYLE=basic` from Base16 to template :(
ERROR: can't convert `themix__PIL_PALETTE_STRICT=False` from Base16 to template :(
ERROR: can't convert `themix__PIL_PALETTE_INVERSE=False` from Base16 to template :(
ERROR: can't convert `themix__PIL_THEME_TEMPLATE=1` from Base16 to template :(
ERROR: can't convert `themix__PIL_IMAGE_PREVIEW=None` from Base16 to template :(
ERROR: can't convert `themix_BASE16_GENERATE_DARK=False` from Base16 to template :(
ERROR: can't convert `themix_BASE16_INVERT_TERMINAL=False` from Base16 to template :(
ERROR: can't convert `themix_BASE16_MILD_TERMINAL=False` from Base16 to template :(
ERROR: can't convert `themix_THEME_STYLE=oomox` from Base16 to template :(
ERROR: can't convert `themix_ROUNDNESS=2` from Base16 to template :(
ERROR: can't convert `themix_GRADIENT=0.0` from Base16 to template :(
ERROR: can't convert `themix_CARET_SIZE=0.04` from Base16 to template :(
ERROR: can't convert `themix_SPACING=3` from Base16 to template :(
ERROR: can't convert `themix_OUTLINE_WIDTH=1` from Base16 to template :(
ERROR: can't convert `themix_BTN_OUTLINE_WIDTH=1` from Base16 to template :(
ERROR: can't convert `themix_BTN_OUTLINE_OFFSET=-3` from Base16 to template :(
ERROR: can't convert `themix_GTK3_GENERATE_DARK=True` from Base16 to template :(
ERROR: can't convert `themix_CINNAMON_OPACITY=1.0` from Base16 to template :(
ERROR: can't convert `themix_UNITY_DEFAULT_LAUNCHER_STYLE=False` from Base16 to template :(
ERROR: can't convert `themix_ICONS_STYLE=gnome_colors` from Base16 to template :(
ERROR: can't convert `themix_SURUPLUS_GRADIENT_ENABLED=False` from Base16 to template :(
ERROR: can't convert `themix_ICONS_NUMIX_STYLE=0` from Base16 to template :(
ERROR: can't convert `themix_TERMINAL_BASE_TEMPLATE=monovedek` from Base16 to template :(
ERROR: can't convert `themix_TERMINAL_THEME_AUTO_BGFG=True` from Base16 to template :(
ERROR: can't convert `themix_TERMINAL_THEME_EXTEND_PALETTE=False` from Base16 to template :(
ERROR: can't convert `themix_TERMINAL_THEME_ACCURACY=128` from Base16 to template :(
ERROR: can't convert `themix_FROM_PLUGIN=base16` from Base16 to template :(
/**
 * Base16 themix_base16 ROFI Color theme
 *
 * Authors
 *  Scheme: themix_base16
 *  Template: Jordi Pakey-Rodriguez (https://github.com/0xdec), Andrea Scarpino (https://github.com/ilpianista)
 */

* {
    red:                         rgba ( 22, 193, 217, 100 % );
    blue:                        rgba ( 0, 188, 212, 100 % );
    lightfg:                     rgba ( 12, 124, 140, 100 % );
    lightbg:                     rgba ( 3, 22, 25, 100 % );
    foreground:                  rgba ( 9, 91, 103, 100 % );
    background:                  rgba ( 2, 16, 18, 100 % );
    background-color:            rgba ( 2, 16, 18, 0 % );
    separatorcolor:              @foreground;
    border-color:                @foreground;
    selected-normal-foreground:  @lightbg;
    selected-normal-background:  @lightfg;
    selected-active-foreground:  @background;
    selected-active-background:  @blue;
    selected-urgent-foreground:  @background;
    selected-urgent-background:  @red;
    normal-foreground:           @foreground;
    normal-background:           @background;
    active-foreground:           @blue;
    active-background:           @background;
    urgent-foreground:           @red;
    urgent-background:           @background;
    alternate-normal-foreground: @foreground;
    alternate-normal-background: @lightbg;
    alternate-active-foreground: @blue;
    alternate-active-background: @lightbg;
    alternate-urgent-foreground: @red;
    alternate-urgent-background: @lightbg;
    spacing:                     2;
}
window {
    background-color: @background;
    border:           1;
    padding:          5;
}
mainbox {
    border:           0;
    padding:          0;
}
message {
    border:           1px dash 0px 0px ;
    border-color:     @separatorcolor;
    padding:          1px ;
}
textbox {
    text-color:       @foreground;
}
listview {
    fixed-height:     0;
    border:           2px dash 0px 0px ;
    border-color:     @separatorcolor;
    spacing:          2px ;
    scrollbar:        true;
    padding:          2px 0px 0px ;
}
element-text, element-icon {
    background-color: inherit;
    text-color:       inherit;
}
element {
    border:           0;
    padding:          1px ;
}
element normal.normal {
    background-color: @normal-background;
    text-color:       @normal-foreground;
}
element normal.urgent {
    background-color: @urgent-background;
    text-color:       @urgent-foreground;
}
element normal.active {
    background-color: @active-background;
    text-color:       @active-foreground;
}
element selected.normal {
    background-color: @selected-normal-background;
    text-color:       @selected-normal-foreground;
}
element selected.urgent {
    background-color: @selected-urgent-background;
    text-color:       @selected-urgent-foreground;
}
element selected.active {
    background-color: @selected-active-background;
    text-color:       @selected-active-foreground;
}
element alternate.normal {
    background-color: @alternate-normal-background;
    text-color:       @alternate-normal-foreground;
}
element alternate.urgent {
    background-color: @alternate-urgent-background;
    text-color:       @alternate-urgent-foreground;
}
element alternate.active {
    background-color: @alternate-active-background;
    text-color:       @alternate-active-foreground;
}
scrollbar {
    width:            4px ;
    border:           0;
    handle-color:     @normal-foreground;
    handle-width:     8px ;
    padding:          0;
}
sidebar {
    border:           2px dash 0px 0px ;
    border-color:     @separatorcolor;
}
button {
    spacing:          0;
    text-color:       @normal-foreground;
}
button selected {
    background-color: @selected-normal-background;
    text-color:       @selected-normal-foreground;
}
inputbar {
    spacing:          0px;
    text-color:       @normal-foreground;
    padding:          1px ;
    children:         [ prompt,textbox-prompt-colon,entry,case-indicator ];
}
case-indicator {
    spacing:          0;
    text-color:       @normal-foreground;
}
entry {
    spacing:          0;
    text-color:       @normal-foreground;
}
prompt {
    spacing:          0;
    text-color:       @normal-foreground;
}
textbox-prompt-colon {
    expand:           false;
    str:              ":";
    margin:           0px 0.3000em 0.0000em 0.0000em ;
    text-color:       inherit;
}

So i thought it will work with yaml files so i made pywal template to generate yaml file just like the files in the schemes folder here is my pywal generated scheme:

scheme: "pywal"
author: "somerandomtext"
base00: "0e1017" 
base01: "58646C"
base02: "666D75"
base03: "737B83"
base04: "5A8584"
base05: "c6c9cc" 
base06: "898F94"
base07: "c6c9cc"
base08: "8a8c8e"
base09: "58646C"
base0A: "666D75"
base0B: "737B83"
base0C: "5A8584"
base0D: "78858C"
base0E: "898F94"
base0F: "c6c9cc"

here is one of the scheme yaml files:

scheme: "Icy Dark"
author: "icyphox (https://icyphox.ga)"
base00: "021012"
base01: "031619"
base02: "041f23"
base03: "052e34"
base04: "064048"
base05: "095b67"
base06: "0c7c8c"
base07: "109cb0"
base08: "16c1d9"
base09: "b3ebf2"
base0A: "80deea"
base0B: "4dd0e1"
base0C: "26c6da"
base0D: "00bcd4"
base0E: "00acc1"
base0F: "0097a7"

but i still go an error when specify mine :

❯ themix-base16-cli /opt/oomox/plugins/base16/templates/rofi/templates/default.mustache /home/jas/.cache/wal/colors_base.yaml 
Import Colors From Image plugin: `colorz` library is not installed - less color-import options are available.
Import Colors From Image plugin: `colorthief` library is not installed - less color-import options are available.
Import Colors From Image plugin: `haishoku` library is not installed - less color-import options are available.
Import Colors From Image plugin: not all optional libraries are installed (see above).
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/opt/oomox/plugins/base16/cli.py", line 41, in <module>
    main()
  File "/opt/oomox/plugins/base16/cli.py", line 31, in main
    read_colorscheme_from_path(themix_theme_path, callback=result.append)
  File "/opt/oomox/plugins/base16/../../oomox_gui/theme_file_parser.py", line 134, in read_colorscheme_from_path
    _set_fallback_values(preset_path, colorscheme, from_plugin)
  File "/opt/oomox/plugins/base16/../../oomox_gui/theme_file_parser.py", line 96, in _set_fallback_values
    colorscheme[key] = parse_theme_value(theme_model_item, colorscheme)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/oomox/plugins/base16/../../oomox_gui/theme_file_parser.py", line 44, in parse_theme_value
    result_value = colorscheme[fallback_key]
                   ~~~~~~~~~~~^^^^^^^^^^^^^^
KeyError: 'MENU_BG'
jas2394 commented 11 months ago

Solution

The issue is with accessing the files, when i put pywal generated file in the schemes dir by making a new dir named pywal inside which is generated pywal.yaml file it works perfectly now.

So the fix is: to set up a sym link to a custom dir created in /opt/oomox/plugins/base16/schemes/customdirname/symlinhere.yaml

here is the themplate for pywal:

scheme: "pywal"
author: "somerandomtext"
base00: "{background.strip}" 
base01: "{color1.strip}"
base02: "{color2.strip}"
base03: "{color3.strip}"
base04: "{color4.strip}"
base05: "{foreground.strip}" 
base06: "{color6.strip}"
base07: "{color7.strip}"
base08: "{color8.strip}"
base09: "{color9.strip}"
base0A: "{color10.strip}"
base0B: "{color11.strip}"
base0C: "{color12.strip}"
base0D: "{color13.strip}"
base0E: "{color14.strip}"
base0F: "{color15.strip}"

put this in ~/.config/wal/templates/filename.yaml and then use following to make the symlink: ln -s ~/.cache/wal/yourFileNameAsInTemplateDir.yaml /opt/oomox/plugins/base16/schemes/customDir/symlink.yaml

actionless commented 10 months ago

in each of your examples you're pointing to the themes in a wrong format for that CLI, the help message says it clearly that it expects themix's own theme

actionless commented 10 months ago

e.g. https://github.com/themix-project/themix-gui/tree/master/colors or user's from ~