mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-01 10:41:03 +02:00
fix(style): file watcher not working for relative paths
Fixes that changes were not hot-loaded when overriding the default style path with `IRONBAR_CSS` and providing a relative file path.
This commit is contained in:
parent
5daeb29c28
commit
976dd6c55a
1 changed files with 8 additions and 0 deletions
|
@ -5,6 +5,7 @@ use gtk::prelude::CssProviderExt;
|
||||||
use gtk::{gdk, gio, CssProvider, StyleContext};
|
use gtk::{gdk, gio, CssProvider, StyleContext};
|
||||||
use notify::event::ModifyKind;
|
use notify::event::ModifyKind;
|
||||||
use notify::{recommended_watcher, Event, EventKind, RecursiveMode, Result, Watcher};
|
use notify::{recommended_watcher, Event, EventKind, RecursiveMode, Result, Watcher};
|
||||||
|
use std::env;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
@ -17,6 +18,13 @@ use tracing::{debug, error, info};
|
||||||
/// Installs a file watcher and reloads CSS when
|
/// Installs a file watcher and reloads CSS when
|
||||||
/// write changes are detected on the file.
|
/// write changes are detected on the file.
|
||||||
pub fn load_css(style_path: PathBuf) {
|
pub fn load_css(style_path: PathBuf) {
|
||||||
|
// file watcher requires absolute path
|
||||||
|
let style_path = if style_path.is_absolute() {
|
||||||
|
style_path
|
||||||
|
} else {
|
||||||
|
env::current_dir().expect("to exist").join(style_path)
|
||||||
|
};
|
||||||
|
|
||||||
let provider = CssProvider::new();
|
let provider = CssProvider::new();
|
||||||
|
|
||||||
match provider.load_from_file(&gio::File::for_path(&style_path)) {
|
match provider.load_from_file(&gio::File::for_path(&style_path)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue