diff options
author | Philippe Brochard <hocwp@free.fr> | 2010-01-23 23:27:28 +0100 |
---|---|---|
committer | Philippe Brochard <hocwp@free.fr> | 2010-01-23 23:27:28 +0100 |
commit | 6ed7b563137fc002dae373e0f8a6362263373000 (patch) | |
tree | 159a340d97e04928533fb64e9b1279ea1b2300fd /xbindkeys.c | |
parent | eeacc6bcbd1ce68fb9741447c71a8fa107ffeb3a (diff) | |
download | xbindkeys-6ed7b563137fc002dae373e0f8a6362263373000.tar.gz |
xbindkeys.c (event_loop): Stat both default rc file and guile rc file for reloading them when they change.
Diffstat (limited to 'xbindkeys.c')
-rw-r--r-- | xbindkeys.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/xbindkeys.c b/xbindkeys.c index d88b34e..0178718 100644 --- a/xbindkeys.c +++ b/xbindkeys.c @@ -51,9 +51,8 @@ static void start_as_daemon (void); Display *current_display; // The current display -#ifndef GUILE_FLAG extern char rc_file[512]; -#else +#ifdef GUILE_FLAG extern char rc_guile_file[512]; #endif @@ -232,54 +231,52 @@ event_loop (Display * d) XEvent e; int i; struct stat rc_file_info; -#ifndef GUILE_FLAG time_t rc_file_changed; -#else +#ifdef GUILE_FLAG time_t rc_guile_file_changed; + struct stat rc_guile_file_info; #endif - XSetErrorHandler ((XErrorHandler) null_X_error); -#ifndef GUILE_FLAG stat(rc_file, &rc_file_info); rc_file_changed = rc_file_info.st_mtime; -#else - stat (rc_guile_file, &rc_file_info); - rc_guile_file_changed = rc_file_info.st_mtime; +#ifdef GUILE_FLAG + stat (rc_guile_file, &rc_guile_file_info); + rc_guile_file_changed = rc_guile_file_info.st_mtime; #endif + while (True) { while(!XPending(d)) { -#ifndef GUILE_FLAG + // if the rc file has been modified, reload it stat (rc_file, &rc_file_info); - if (rc_file_info.st_mtime != rc_file_changed) - { - reload_rc_file (); - if (verbose) - { - printf ("The rc file has been modified, reload it\n"); - } - rc_file_changed = rc_file_info.st_mtime; - } -#else +#ifdef GUILE_FLAG // if the rc guile file has been modified, reload it - stat (rc_guile_file, &rc_file_info); - if (rc_file_info.st_mtime != rc_guile_file_changed) + stat (rc_guile_file, &rc_guile_file_info); +#endif + + if (rc_file_info.st_mtime != rc_file_changed +#ifdef GUILE_FLAG + || rc_guile_file_info.st_mtime != rc_guile_file_changed +#endif + ) { reload_rc_file (); if (verbose) { - printf ("The rc guile file has been modified, reload it\n"); + printf ("The configuration file has been modified, reload it\n"); } - rc_guile_file_changed = rc_file_info.st_mtime; - } + rc_file_changed = rc_file_info.st_mtime; +#ifdef GUILE_FLAG + rc_guile_file_changed = rc_guile_file_info.st_mtime; #endif + } usleep(SLEEP_TIME*1000); } |