mirror of
https://github.com/hyprwm/Hyprland
synced 2025-12-24 09:10:03 +01:00
32 lines
No EOL
825 B
C++
32 lines
No EOL
825 B
C++
#pragma once
|
|
#include "../helpers/memory/Memory.hpp"
|
|
#include <vector>
|
|
#include <string>
|
|
#include <functional>
|
|
|
|
class CConfigWatcher {
|
|
public:
|
|
CConfigWatcher();
|
|
~CConfigWatcher();
|
|
|
|
struct SConfigWatchEvent {
|
|
std::string file;
|
|
};
|
|
|
|
int getInotifyFD();
|
|
void setWatchList(const std::vector<std::string>& paths);
|
|
void setOnChange(const std::function<void(const SConfigWatchEvent&)>& fn);
|
|
void onInotifyEvent();
|
|
|
|
private:
|
|
struct SInotifyWatch {
|
|
int wd = -1;
|
|
std::string file;
|
|
};
|
|
|
|
std::function<void(const SConfigWatchEvent&)> m_watchCallback;
|
|
std::vector<SInotifyWatch> m_watches;
|
|
int m_inotifyFd = -1;
|
|
};
|
|
|
|
inline UP<CConfigWatcher> g_pConfigWatcher = makeUnique<CConfigWatcher>(); |