Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Communicate syncmode to synchooks #86

Merged

Conversation

dopefishh
Copy link
Contributor

This patch sets the environment variable OFFLINEIMAPSYNCMODE to either
full, quick or idle depending on the context of the pre- and
postsynchook.

Adding the context as an argument was considered but this would break
existing configurations and it makes calling a program directly more
cumbersome. Some programs (e.g. imapfilter) may not know what to do with
this extra argument.

This PR

  • I've read the DCO.
  • I've read the Coding Guidelines
  • The relevant informations about the changes stands in the commit message, not here in the message of the pull request.
  • Code changes follow the style of the files they change.
  • Code is tested (provide details).

References

Additional information

This patch sets the environment variable OFFLINEIMAPSYNCMODE to either
full, quick or idle depending on the context of the pre- and
postsynchook.

Adding the context as an argument was considered but this would break
existing configurations and it makes calling a program directly more
cumbersome. Some programs (e.g. imapfilter) may not know what to do with
this extra argument.

Signed-off-by: Mart Lubbers <[email protected]>
@thekix
Copy link
Member

thekix commented Oct 12, 2021

Dear @dopefishh

Thanks a lot for your patch.

please, can you provide more info about it? Sorry, but I cannot understand how this patch could be used. Could you provide some examples?

Thanks a lot,
Best regards,
kix

@dopefishh
Copy link
Contributor Author

Thanks, the idea is that a post/presynchook can check whether offlineimap is syncing in full or quick mode. For example, syncing a calendar may only be needed on full syncs (e.g. every hour). On the other hand, updating the new mail indicator or the notmuch database is desirable on every sync (e.g. every five minutes).

For example, this is my postsynchook:

#!/bin/sh
# update the notmuch database
notmuch new

# signal the status bar to force refresh
killall -s SIGUSR1 slstatus

# if the syncmode is full, update the calendars
if [ "$OFFLINEIMAPSYNCMODE" = full ]
then
        vdirsyncer sync --max-workers=1
fi

@nicolas33
Copy link
Member

LGTM

@thekix thekix merged commit 253f97a into OfflineIMAP:master Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants