Better file watches
This commit is contained in:
parent
790d1edf76
commit
1543d57979
|
@ -162,16 +162,15 @@ in
|
|||
value = mkService name account;
|
||||
};
|
||||
hasImapHost = name: account: account.imap != null;
|
||||
mkEntrService = name: account: {
|
||||
name = "entr-watch-${name}-maildir";
|
||||
mkWatchService = name: account: {
|
||||
name = "watch-${name}-maildir";
|
||||
value = {
|
||||
Unit.Description = "Watch maildir for changes for account ${name}";
|
||||
Service = {
|
||||
ExecStart = toString (pkgs.writeShellScript "entr-watch-${name}-maildir" ''
|
||||
ExecStart = toString (pkgs.writeShellScript "watch-${name}-maildir" ''
|
||||
while sleep 1s; do
|
||||
echo "Watching the following files or directories:"
|
||||
${pkgs.fd}/bin/fd . ${maildir}/${name}/Inbox
|
||||
${pkgs.fd}/bin/fd . ${maildir}/${name}/Inbox | ${pkgs.entr}/bin/entr -n -d ${quick-sync}
|
||||
${quick-sync}
|
||||
${pkgs.inotify-tools}/bin/inotifywait -e move,create,delete -r ${maildir}/${name}/Inbox
|
||||
done
|
||||
'');
|
||||
};
|
||||
|
@ -179,7 +178,7 @@ in
|
|||
};
|
||||
};
|
||||
in
|
||||
lib.mapAttrs' mkEntrService
|
||||
lib.mapAttrs' mkWatchService
|
||||
(lib.filterAttrs hasImapHost config.accounts.email.accounts) // lib.mapAttrs' mkServiceWithName
|
||||
(lib.filterAttrs hasImapHost config.accounts.email.accounts) // {
|
||||
mbsync.Service = {
|
||||
|
|
|
@ -79,13 +79,14 @@ in
|
|||
home.packages = [ pkgs.vdirsyncer ];
|
||||
|
||||
systemd.user = {
|
||||
services.entr-watch-vdir = {
|
||||
services.watch-vdir = {
|
||||
Unit.Description = "Watch vdir data for changes";
|
||||
Service = {
|
||||
ExecStart = toString (
|
||||
pkgs.writeShellScript "entr-watch-vdir" ''
|
||||
pkgs.writeShellScript "watch-vdir" ''
|
||||
while sleep 1s; do
|
||||
${pkgs.fd}/bin/fd . ${config.home.homeDirectory}/.contacts ${config.home.homeDirectory}/.calendars | ${pkgs.entr}/bin/entr -n -d ${pkgs.vdirsyncer}/bin/vdirsyncer sync
|
||||
${pkgs.vdirsyncer}/bin/vdirsyncer sync
|
||||
${pkgs.inotify-tools}/bin/inotifywait -e move,create,delete,modify -r ${config.home.homeDirectory}/.contacts ${config.home.homeDirectory}/.calendars
|
||||
done
|
||||
''
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue