From 945418bebffca98f658e726da3100a5b4a6bb51c Mon Sep 17 00:00:00 2001 From: sefidel Date: Mon, 14 Feb 2022 23:59:40 +0900 Subject: chore: fix mail oneshot --- home/profiles/messaging/default.nix | 38 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'home') diff --git a/home/profiles/messaging/default.nix b/home/profiles/messaging/default.nix index 54d6870..946bcb8 100644 --- a/home/profiles/messaging/default.nix +++ b/home/profiles/messaging/default.nix @@ -41,8 +41,6 @@ in boxes = [ "Inbox" ]; onNotify = pkgs.writeShellScript "imap-on-notify" '' ${mbsyncCmd} zach - NOTMUCH_CONFIG=${lib.escapeShellArg config.home.sessionVariables.NOTMUCH_CONFIG} - NMBGIT=${lib.escapeShellArg config.home.sessionVariables.NMBGIT} ${pkgs.notmuch}/bin/notmuch new ''; }; @@ -183,21 +181,22 @@ in services.imapnotify.enable = true; # Sync emails on initial login - systemd.user.services.mbsync-initial = { + systemd.user.services.mbsync-oneshot = { Unit = { - Description = "mbsync initial synchronisation"; - After = "graphical-session.target"; + Description = "mbsync oneshot synchronisation"; }; Service = { + Type = "oneshot"; ExecStart = "${mbsyncCmd} --all"; - Restart = "on-failure"; + RemainAfterExit = true; }; Install.WantedBy = [ "default.target" ]; }; - home.file.".mailcap".text = let - setsid = "${pkgs.util-linux}/bin/setsid"; - openfile = "${pkgs.writeShellScript "openfile" '' + home.file.".mailcap".text = + let + setsid = "${pkgs.util-linux}/bin/setsid"; + openfile = "${pkgs.writeShellScript "openfile" '' # Helps open a file with xdg-open from mutt in a external program without weird side effects. tempdir="''${TMPDIR:-$(mktemp -d)}" file="$tempdir/$(basename "$1")" @@ -207,17 +206,16 @@ in $opener "$file" >/dev/null 2>&1 find "''${tempdir:?}" -mtime +1 -type f -delete ''}"; - in '' - ${lib.optionalString false "text/html; ${pkgs.w3m}/bin/w3m -dump -T text/html -I %{charset} -O utf-8 %s; copiousoutut; description=HTML Text; nametemplate=%s.html"} - - - text/plain; $EDITOR %s ; - ${lib.optionalString true "text/html; ${openfile} %s ; nametemplate=%s.html"} - text/html; ${pkgs.lynx}/bin/lynx -assume_charset=%{charset} -display_charset=utf-8 -dump %s; nametemplate=%s.html; copiousoutput; - image/*; ${openfile} %s ; - application/pdf; ${openfile} %s ; - # application/pgp-encrypted; gpg -d '%s'; copiousoutput; - ''; + in + '' + ${lib.optionalString false "text/html; ${pkgs.w3m}/bin/w3m -dump -T text/html -I %{charset} -O utf-8 %s; copiousoutut; description=HTML Text; nametemplate=%s.html"} + text/plain; $EDITOR %s ; + ${lib.optionalString true "text/html; ${openfile} %s ; nametemplate=%s.html"} + text/html; ${pkgs.lynx}/bin/lynx -assume_charset=%{charset} -display_charset=utf-8 -dump %s; nametemplate=%s.html; copiousoutput; + image/*; ${openfile} %s ; + application/pdf; ${openfile} %s ; + # application/pgp-encrypted; gpg -d '%s'; copiousoutput; + ''; home.packages = with pkgs; [ element-desktop -- cgit 1.4.1