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