mirror of
https://github.com/gryf/wmaker.git
synced 2026-03-21 19:03:31 +01:00
wmaker: filter inotify events only to expected config files
This patch is checking if the notification wmaker is receiving from the Defaults directory is coming from a proper expected config file. Until now, using vim for example to open any of the files, for example WMRootMenu would reload the configs, even before saving the file. You would see in the logs: warning: Inotify: Reading config files in defaults database. because vim by default is creating a .swp file in that same directory.
This commit is contained in:
committed by
Carlos R. Mafra
parent
c6f029c946
commit
b27b44db72
20
src/event.c
20
src/event.c
@@ -357,11 +357,29 @@ static void handle_inotify_events(void)
|
|||||||
|
|
||||||
wPreferences.flags.noupdates = 1;
|
wPreferences.flags.noupdates = 1;
|
||||||
}
|
}
|
||||||
if ((pevent->mask & IN_MODIFY) && oneShotFlag == 0) {
|
/* Only react when a known config file inside the Defaults directory is affected */
|
||||||
|
if (pevent->len > 0) {
|
||||||
|
char *fname = pevent->name;
|
||||||
|
const char *allowed[] = { "WMRootMenu", "WMWindowAttributes",
|
||||||
|
"WindowMaker", "WMState", "WMGLOBAL", NULL };
|
||||||
|
int i, matched = 0;
|
||||||
|
|
||||||
|
for (i = 0; allowed[i]; i++) {
|
||||||
|
if (strcmp(fname, allowed[i]) == 0) {
|
||||||
|
matched = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matched) {
|
||||||
|
/* react to events that indicate a file was created/moved/written */
|
||||||
|
if ((pevent->mask & (IN_MODIFY | IN_CLOSE_WRITE | IN_MOVED_TO | IN_CREATE)) && oneShotFlag == 0) {
|
||||||
wwarning(_("Inotify: Reading config files in defaults database."));
|
wwarning(_("Inotify: Reading config files in defaults database."));
|
||||||
wDefaultsCheckDomains(NULL);
|
wDefaultsCheckDomains(NULL);
|
||||||
oneShotFlag = 1;
|
oneShotFlag = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* move to next event in the buffer */
|
/* move to next event in the buffer */
|
||||||
i += sizeof(struct inotify_event) + pevent->len;
|
i += sizeof(struct inotify_event) + pevent->len;
|
||||||
|
|||||||
Reference in New Issue
Block a user