tinted-theming / tinty

A base16 and base24 color scheme manager
MIT License
43 stars 4 forks source link

[Question] way detect if theme is light or dark #71

Open ckjoris opened 4 days ago

ckjoris commented 4 days ago

What version of tinty are you using? tinty 0.18.0

Hi, is there a way to detect if the current theme is dark or light, or just read the 'variant' from the theme file?

I want to script this detection, so could pass the appropriate theme argument to other cli tools.

Currently having to do a bit of a workaround in the shell handler:

# tinty config
[[items]]
name = "base16-shell"
path = "https://github.com/tinted-theming/base16-shell"
hook = "cat %f > ~/.base16_theme && using_tinty=true ~/dotfiles/base16_handler_shell.sh ; . %f"
# ~/dotfiles/base16_handler_shell.sh
# get the yaml file
yaml_path=$(tinty info "$(tinty current)" | grep -Poi '\@\K.*(.*.yaml)')
# strip the leading and trailing whitespaces
yaml_path=$(echo "$yaml_path" | xargs)

$(grep "variant" "$yaml_path" | grep --silent -i "light")
is_light=$?
echo "$is_light" >> ~/.base16_theme_light
JamyGolden commented 4 days ago

Interesting, yes I do see the value having tinty solve your issue. I'll look at fleshing out the tinty current subcommand to accept args for the meta info of the scheme, for example tinty current variant and tinty current author. What do you think of that?

ckjoris commented 3 days ago

yes I do see the value having tinty solve your issue.

great!

yes, sounds like tinty current variant command would exactly solve my needs

JamyGolden commented 17 hours ago

I've created a PR for the feature: https://github.com/tinted-theming/tinty/pull/72

I'll merge in a day or so