diff options
| author | Mihai Fufezan <mihai@fufexan.net> | 2025-01-31 15:36:22 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-31 14:36:22 +0100 |
| commit | 12b5034c99f28025e6c6be29c33bde9f4a24ac9f (patch) | |
| tree | deabe960411a91ce4189770ca4f82a9a59d2ad28 /src/config/ConfigWatcher.cpp | |
| parent | 9c38287410b305503f921e411eb39686b23ccc42 (diff) | |
configWatcher: watch both symlinks and canonical paths (#9219)
Diffstat (limited to 'src/config/ConfigWatcher.cpp')
| -rw-r--r-- | src/config/ConfigWatcher.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/config/ConfigWatcher.cpp b/src/config/ConfigWatcher.cpp index 8d086bac..e5db1e86 100644 --- a/src/config/ConfigWatcher.cpp +++ b/src/config/ConfigWatcher.cpp @@ -4,6 +4,7 @@ #include <ranges> #include <fcntl.h> #include <unistd.h> +#include <filesystem> using namespace Hyprutils::OS; @@ -43,9 +44,19 @@ void CConfigWatcher::setWatchList(const std::vector<std::string>& paths) { // add new paths for (const auto& path : paths) { m_watches.emplace_back(SInotifyWatch{ - .wd = inotify_add_watch(m_inotifyFd.get(), path.c_str(), IN_MODIFY), + .wd = inotify_add_watch(m_inotifyFd.get(), path.c_str(), IN_MODIFY | IN_DONT_FOLLOW), .file = path, }); + + std::error_code ec, ec2; + const auto CANONICAL = std::filesystem::canonical(path, ec); + const auto IS_SYMLINK = std::filesystem::is_symlink(path, ec2); + if (!ec && !ec2 && IS_SYMLINK) { + m_watches.emplace_back(SInotifyWatch{ + .wd = inotify_add_watch(m_inotifyFd.get(), CANONICAL.c_str(), IN_MODIFY), + .file = path, + }); + } } } |
