JakeStanger / ironbar

Customisable Wayland gtk bar written in Rust.
https://crates.io/crates/ironbar
MIT License
536 stars 44 forks source link

Hot reload css files imported in style.css #468

Open helixoid opened 6 months ago

helixoid commented 6 months ago

I am using wallust (rust replacement for pywal) and whenever I change my colorscheme it doesn't reload the css colors stored in ~/.cache/wal/colors.css but if I open and save the style.css file, it reloads the css style.

I know I can do ironbar load-css to hot-reload any external css file, but it would be awesome if ironbar hot-reloads the css files imported with @import in style.css by default.

Currently I have exec-once = sleep 3; ironbar load-css ~/.cache/wal/colors.css in my hyprland.conf which does the job.

Let me know if this is possible to do in future.

JakeStanger commented 6 months ago

From a quick glance through the GTK API docs, this may be possible if I can easily parse the imports.

The file watcher watches the stylesheet's parent directory for changes in order to support temp files from editors such as vim. This would need to be repeated for every import, and I guess ideally recursively in case an import handles an import. The logic around that might get a little tricky and I don't want to overcomplicate things, so I'll see what I can do.

helixoid commented 6 months ago

It works on waybar have a look at the last option in bar config. The "reload_style_on_change": true option makes it work like that and I have tested it. I really like this project more than waybar mainly because of rust :) and favorite workspaces hope it makes it to the next release.

JakeStanger commented 6 months ago

Cheers for that, good to know it's at least possible. It looks like they just pull out the import paths with a regex. I'd prefer to...not do that if possible but I'll have a play, and resort to that if needed.

To set realistic expectations, it's unlikely I'll get to this myself for a while, and almost certainly not for next release as I've got a big pile of issues to work through. If anybody else wants to pick this up though, PRs are welcome as always :)