~magic_rb/dotfiles

49504a10e8ff9ec9d355deaf72859ec56431d2ba — Magic_RB 8 months ago 77c18a2
add a emacs service and defer ement using a sentinel

Signed-off-by: Magic_RB <magic_rb@redalder.org>
2 files changed, 39 insertions(+), 4 deletions(-)

M emacs-lisp/ement_el.org
M home-manager/modules/emacs/default.nix
M emacs-lisp/ement_el.org => emacs-lisp/ement_el.org +14 -4
@@ 7,6 7,19 @@
#+begin_src emacs-lisp
  (use-package password-store
    :straight t)

  (defun ement-connect-sentinel (process msg)
    (when (memq (process-status process) '(exit signal))
      (with-current-buffer " *ement-pass*"
        (ement-connect
         :uri-prefix "http://localhost:8008"
         :password (string-trim (substring-no-properties (buffer-string)))
         :user-id "@magic_rb:matrix.redalder.org")
        (kill-buffer))))

  (defun after-init-ement-connect ()
    (set-process-sentinel (start-process "ement-pass" " *ement-pass*" "pass" "Matrix/@magic_rb:matrix.redalder.org") #'ement-connect-sentinel))

  (use-package ement
    :straight '(ement :type git :host github :repo "alphapapa/ement.el")
    :after (password-store)


@@ 14,10 27,7 @@
    (ement-save-sessions t)
    :config
    (remove-hook 'ement-after-initial-sync-hook #'ement-room-list--after-initial-sync)
    (ement-connect
     :uri-prefix "http://localhost:8008"
     :password (password-store-get "Matrix/@magic_rb:matrix.redalder.org")
     :user-id "@magic_rb:matrix.redalder.org"))
    (add-hook 'after-init-hook #'after-init-ement-connect))
#+end_src

#+begin_src emacs-lisp

M home-manager/modules/emacs/default.nix => home-manager/modules/emacs/default.nix +25 -0
@@ 92,6 92,31 @@ in {
        ln -sfn ~/dotfiles/home-manager/modules/emacs/straight-versions.el ~/.emacs.d/straight/versions/default.el
      '';

    systemd.user.services.emacs = {
      Unit = {
         After = "graphical-session.target";
         PartOf = "graphical-session.target";
         X-RestartIfChanged = false;
      };

      Service = {
        Type = "notify";
        ExecStart = ''${pkgs.runtimeShell} -l -c "${lib.getExe cfg.package} --fg-daemon"'';

        # Emacs will exit with status 15 after having received SIGTERM, which
        # is the default "KillSignal" value systemd uses to stop services.
        SuccessExitStatus = 15;

        Restart = "on-failure";
      };

      Install = {
        WantedBy = [
          "graphical-session.target"
        ];
      };
    };

    home.file = {
      ".emacs".source = ./.emacs;
      ".mbsyncrc" = mkIf cfg.enableMu4e {