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

[Feature request] skip the hook if it is not apply #70

Closed
twnaing opened this issue Sep 30, 2024 · 8 comments
Closed

[Feature request] skip the hook if it is not apply #70

twnaing opened this issue Sep 30, 2024 · 8 comments
Assignees

Comments

@twnaing
Copy link

twnaing commented Sep 30, 2024

Is your feature request related to a problem? Please describe.

No, it is not.

Describe the solution you'd like

Solution: skip the hook if it is not apply

Reason: there are cases where hook is used to create config file such as copying the template file cp -f %f ~/.config/i3/color. Such kind of hook is only required when we are applying new theme, AFAIK. If we can skip the hook on init we can increase speed and reduce resource usage.

Describe alternatives you've considered

The alternative could be

a. different hooks for apply and init
b. pass init or apply to hook as a template variable and deal with the resource usage in the hook command

Additional context

The following config always create config file and reload the i3 every time tinty init is called.

# ... global config
[[items]]
name = "base16-i3"
path = "https://github.com/tinted-theming/base16-i3"
themes-dir = "colors"
hook = "cp -f %f ~/.config/i3/colors && cat ~/.config/i3/colors ~/.config/i3/base > ~/.config/i3/config && i3-msg reload"
@JamyGolden
Copy link
Member

Thanks for creating the issue. What would imagine the config item look like for this? hook_init and hook for normal and hook is executed if hook_init doesn't exist for init? Trying to figure out a way to get it done without making it overly complex

@twnaing
Copy link
Author

twnaing commented Oct 2, 2024

On a second thought, I think I am having this feature request because

  • init and apply do the almost same thing and
  • I do init in every terminal I open. (USAGE.md instruction do the init while aliasing tinty_source_shell_theme)

Currently

  • omitting the init in shell *rc (and refraining myself from using tinty init)
  • sourcing only the tinted-shell script on terminal open
  • having all the resource expensive hooks (and using tinty apply when I want to change theme)

works the way I want.

Making two hooks seem complex.

@JamyGolden
Copy link
Member

I'm glad you've got it working like you'd like. Yeah I do see the issue with init and apply and how it can be confusing. init is currently basically tinty apply $(tinty current) which does make me question the necessity of init subcommand in the first place if it's not very different from apply.

@twnaing
Copy link
Author

twnaing commented Oct 3, 2024

As Tinty have already offloaded "a bit of work" to the hook, passing of the command (init or apply as a template variable) to hook could be less complicated.

Users will have the freedom to do what they want in the hook.

Just a opinion.

@JamyGolden
Copy link
Member

Can you give a config.yaml example of that suggestion?

@twnaing
Copy link
Author

twnaing commented Oct 3, 2024

assume %m is command mode (i.e. init or apply) the config will be like

[[items]]
name = "base16-i3"
path = "https://github.com/tinted-theming/base16-i3"
themes-dir = "colors"
hook = '[ "%m" = "apply" ] && cp -f %f ~/.config/i3/colors && cat ~/.config/i3/colors ~/.config/i3/base > ~/.config/i3/config && i3-msg reload'

@JamyGolden
Copy link
Member

Added a PR for this: #73

@JamyGolden
Copy link
Member

Just released the changes, let me know if things aren't as expected.

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

2 participants