diff options
author | Jesse Luehrs <doy@tozt.net> | 2022-02-16 04:12:02 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2022-02-16 04:12:02 -0500 |
commit | a2290a2b76c4740a4e2cc2c176797cc1981a46a2 (patch) | |
tree | a295a07a6e191e5f90e513e093a946a1904765f1 /bin | |
parent | 11b4db95dc4fb8e1977f8c39b72e1cb01a66f6b5 (diff) | |
download | conf-a2290a2b76c4740a4e2cc2c176797cc1981a46a2.tar.gz conf-a2290a2b76c4740a4e2cc2c176797cc1981a46a2.zip |
also make the poll interval configurable
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/mbsyncloop | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/bin/mbsyncloop b/bin/mbsyncloop index 0327c4e..a1cf181 100755 --- a/bin/mbsyncloop +++ b/bin/mbsyncloop @@ -58,9 +58,9 @@ sub main { ); loop( + $config_data, $generated_mbsync_config_file, $goimapnotify_r, - $config_data->{on_new_mail}, ); } @@ -224,18 +224,27 @@ EOF } sub loop { - my ($mbsync_config, $goimapnotify_r, $on_new_mail) = @_; + my ($config_data, $mbsync_config, $goimapnotify_r) = @_; + my $poll_interval = $config_data->{poll_interval} // 15 * 60; my $last_all = 0; $SIG{HUP} = sub { $last_all = 0 }; while (1) { my $now = time; - if (($now - $last_all) >= 14 * 60) { - sync($mbsync_config, "mbsyncloop_all", $on_new_mail); + if (($now - $last_all) >= $poll_interval) { + sync( + $mbsync_config, + "mbsyncloop_all", + $config_data->{on_new_mail}, + ); $last_all = $now; } - if (idle($goimapnotify_r, 15 * 60 - (time - $now))) { - sync($mbsync_config, "mbsyncloop_priority", $on_new_mail); + if (idle($goimapnotify_r, $poll_interval)) { + sync( + $mbsync_config, + "mbsyncloop_priority", + $config_data->{on_new_mail}, + ); } } } |