matugen icon indicating copy to clipboard operation
matugen copied to clipboard

[Request] Add live refresh for following apps

Open zDyant opened this issue 1 year ago • 8 comments

These apps don't auto reload, and need these commands to read new colors

App: command

bat: bat cache --build swaync: swayns-client -rs

zDyant avatar Jul 22 '24 00:07 zDyant

It would be nice to add rofi and swayosd too

NotMephisto avatar Aug 10 '24 13:08 NotMephisto

I suggest adding an option to the TOML config file under the template section, such as exec, or perhaps splitting it into pre_exec and post_exec. This option would allow users to specify a shell command to be executed automatically.

  • The exec option would run the specified command after the template generation is complete.
  • Alternatively, the pre_exec option could run the command before generation, and the post_exec option could run it after generation.

I believe this approach would be more effective than implementing commands for each requested app individually. It would give users the flexibility to restart or perform any necessary actions before or after generating templates according to their needs.


I recall something similar might have been added before, possibly called hook, but it’s not mentioned in the documentation, so I’m unsure if it’s the same feature or something different. I am talking about https://github.com/InioX/matugen/issues/83#issuecomment-2197180474


Anyway, Here’s an example using the exec approach:

[templates.swaync]
input_path = '~/.config/swaync/style-template.css'
output_path = '~/.config/swaync/style.css'
exec = 'swaync-client --reload-config && swaync-client --reload-css'

And here’s an example using the {pre/post}_exec approach:

[templates.some_app]
input_path = '~/.config/some_app/template.ext'
output_path = '~/.config/some_app/generated.ext'
pre_exec = 'echo "before generating" >> ~/logs'
post_exec = 'echo "after generating" >> ~/logs'

Davenchy avatar Aug 12 '24 07:08 Davenchy

I've also been thinking of automatically reloading when the template has a specific name like sway or something else. Every template would have an option to enable/disable the auto reload.

InioX avatar Aug 13 '24 17:08 InioX

I've also been thinking of automatically reloading when the template has a specific name like sway or something else. Every template would have an option to enable/disable the auto reload.

This would be a great feature. However, my suggestion to implement after/before generation hooks is to allow users to write custom scripts tailored to their own environments. From my perspective, adding specific code for auto-reloading based on template names like sway could lead to more complex code, additional requests to support other tools, and potential future bugs and code maintenance issues.

Davenchy avatar Aug 15 '24 07:08 Davenchy

I already added the pre_hook and post_hook stuff in #100.

InioX avatar Aug 15 '24 09:08 InioX

honestly I don't think this is a good idea. We should just make a directory of example hooks so that users can simply copy/paste.

DaniD3v avatar Aug 18 '24 17:08 DaniD3v

honestly I don't think this is a good idea. We should just make a directory of example hooks so that users can simply copy/paste.

I didn't get your idea. Could you make it clear? Like, What do you mean by saying hooks and example hooks?

Davenchy avatar Aug 19 '24 06:08 Davenchy

Take a look at #100

DaniD3v avatar Aug 19 '24 10:08 DaniD3v