mirror of
https://github.com/polybar/polybar.git
synced 2026-02-19 06:15:31 +00:00
Also monitor include-files for changes when --reload is set (#2759)
* fixes #675 * feat(configwatcher): method to create config monitor handler * cleanup Co-authored-by: patrick96 <p.ziegler96@gmail.com>
This commit is contained in:
@ -195,6 +195,16 @@ void controller::signal_handler(int signum) {
|
||||
stop(signum == SIGUSR1);
|
||||
}
|
||||
|
||||
void controller::create_config_watcher(const string& filename) {
|
||||
auto& fs_event_handler = m_loop.handle<FSEventHandle>();
|
||||
fs_event_handler.start(
|
||||
filename, 0, [this](const auto& e) { confwatch_handler(e.path); },
|
||||
[this, &fs_event_handler](const auto& e) {
|
||||
m_log.err("libuv error while watching included file for changes: %s", uv_strerror(e.status));
|
||||
fs_event_handler.close();
|
||||
});
|
||||
}
|
||||
|
||||
void controller::confwatch_handler(const char* filename) {
|
||||
m_log.notice("Watched config file changed %s", filename);
|
||||
stop(true);
|
||||
@ -251,13 +261,11 @@ void controller::read_events(bool confwatch) {
|
||||
}
|
||||
|
||||
if (confwatch) {
|
||||
auto& fs_event_handle = m_loop.handle<FSEventHandle>();
|
||||
fs_event_handle.start(
|
||||
m_conf.filepath(), 0, [this](const auto& e) { confwatch_handler(e.path); },
|
||||
[this, &fs_event_handle](const auto& e) {
|
||||
m_log.err("libuv error while watching config file for changes: %s", uv_strerror(e.status));
|
||||
fs_event_handle.close();
|
||||
});
|
||||
create_config_watcher(m_conf.filepath());
|
||||
// also watch the include-files for changes
|
||||
for (auto& module_path : m_conf.get_included_files()) {
|
||||
create_config_watcher(module_path);
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_snapshot_dst.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user