#pragma once #include #include #include #include #include #include #include struct pollfd; namespace waybar { class CssReloadHelper { public: CssReloadHelper(std::string cssFile, std::function callback); ~CssReloadHelper(); virtual void monitorChanges(); void stop(); protected: std::vector parseImports(const std::string& cssFile); void parseImports(const std::string& cssFile, std::unordered_map& imports); void watchFiles(const std::vector& files); bool handleInotifyEvents(int fd); bool watch(int inotifyFd, pollfd * pollFd); virtual std::string getFileContents(const std::string& filename); virtual std::string findPath(const std::string& filename); private: std::string m_cssFile; std::function m_callback; std::atomic m_running = false; std::thread m_thread; std::mutex m_mutex; std::condition_variable m_cv; }; } // namespace waybar