Use emacsclient to update mu index to make sure the db isn't locked

This commit is contained in:
Charlotte Van Petegem 2021-03-22 13:46:31 +01:00
parent 2808ce7436
commit 8e1b901372
No known key found for this signature in database
GPG key ID: 019E764B7184435A
6 changed files with 401 additions and 377 deletions

View file

@ -1,10 +1,12 @@
{ pkgs, ... }: { config, pkgs, ... }:
let let
launcher = import ./sway/launcher.nix { inherit pkgs; stdenv = pkgs.stdenv; }; launcher = import ./sway/launcher.nix { inherit pkgs; stdenv = pkgs.stdenv; };
status-configuration = import ./sway/status-configuration.nix { inherit pkgs; }; status-configuration = import ./sway/status-configuration.nix { inherit pkgs config; };
in in
{ {
imports = [ ./base-x.nix ]; imports = [ ./base-x.nix ];
config = {
home-manager.users.charlotte = { pkgs, ... }: { home-manager.users.charlotte = { pkgs, ... }: {
xsession = { xsession = {
windowManager.i3 = { windowManager.i3 = {
@ -37,4 +39,5 @@ in
}; };
}; };
}; };
};
} }

View file

@ -1,4 +1,4 @@
{ pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
passwordScript = pkgs.writeShellScript "get_mail_password" ''${pkgs.pass}/bin/pass show "$@" | head -n1 | tr -d "\n"''; passwordScript = pkgs.writeShellScript "get_mail_password" ''${pkgs.pass}/bin/pass show "$@" | head -n1 | tr -d "\n"'';
notifyScript = name: pkgs.writeShellScript "notify_${name}_mail" '' notifyScript = name: pkgs.writeShellScript "notify_${name}_mail" ''
@ -28,7 +28,7 @@ let
enable = true; enable = true;
boxes = [ "INBOX" ]; boxes = [ "INBOX" ];
onNotify = "${pkgs.isync}/bin/mbsync ${name}:INBOX"; onNotify = "${pkgs.isync}/bin/mbsync ${name}:INBOX";
onNotifyPost = "${pkgs.mu}/bin/mu index && ${notifyScript name}"; onNotifyPost = "${config.chvp.emacs.package}/bin/emacsclient --eval \"(mu4e-update-index)\" && ${notifyScript name}";
}; };
mbsync = { mbsync = {
enable = true; enable = true;
@ -75,6 +75,7 @@ let
toRecursiveINIBase 1; toRecursiveINIBase 1;
in in
{ {
config = {
chvp.zfs.homeLinks = [ chvp.zfs.homeLinks = [
{ path = "mail"; type = "data"; } { path = "mail"; type = "data"; }
{ path = ".cache/mu"; type = "cache"; } { path = ".cache/mu"; type = "cache"; }
@ -277,7 +278,7 @@ in
}; };
Service = { Service = {
Type = "oneshot"; Type = "oneshot";
ExecStart = [ "${pkgs.isync}/bin/mbsync -a" "${pkgs.mu}/bin/mu index" ]; ExecStart = [ "${pkgs.isync}/bin/mbsync -a" "${config.chvp.emacs.package}/bin/emacsclient --eval \"(mu4e-update-index)\"" ];
}; };
}; };
vdirsyncer = { vdirsyncer = {
@ -312,4 +313,5 @@ in
}; };
}; };
}; };
};
} }

View file

@ -1,11 +1,12 @@
{ pkgs, ... }: { config, pkgs, ... }:
let let
launcher = import ./sway/launcher.nix { inherit pkgs; stdenv = pkgs.stdenv; }; launcher = import ./sway/launcher.nix { inherit pkgs; stdenv = pkgs.stdenv; };
color-picker = import ./sway/color-picker.nix { inherit pkgs; }; color-picker = import ./sway/color-picker.nix { inherit pkgs; };
screenshot = import ./sway/screenshot.nix { inherit pkgs; }; screenshot = import ./sway/screenshot.nix { inherit pkgs; };
status-configuration = import ./sway/status-configuration.nix { inherit pkgs; }; status-configuration = import ./sway/status-configuration.nix { inherit pkgs config; };
in in
{ {
config = {
services.dbus.packages = with pkgs; [ gnome3.dconf ]; services.dbus.packages = with pkgs; [ gnome3.dconf ];
security.pam.services.swaylock = { }; security.pam.services.swaylock = { };
xdg.portal = { xdg.portal = {
@ -158,4 +159,5 @@ in
xwayland = true; xwayland = true;
}; };
}; };
};
} }

View file

@ -1,4 +1,4 @@
{ pkgs, ... }: { config, pkgs, ... }:
let let
mic-status = pkgs.writeShellScript "mic-status" '' mic-status = pkgs.writeShellScript "mic-status" ''
if [ "$(${pkgs.pulseaudio}/bin/pactl list sources | grep -o 'Mute: yes')" = "Mute: yes" ] if [ "$(${pkgs.pulseaudio}/bin/pactl list sources | grep -o 'Mute: yes')" = "Mute: yes" ]
@ -95,7 +95,7 @@ pkgs.writeText "configuration.toml" ''
json = true json = true
command = "${mail-status}" command = "${mail-status}"
interval = 1 interval = 1
on_click = "${pkgs.isync}/bin/mbsync -a" on_click = "${pkgs.isync}/bin/mbsync -a && ${config.chvp.emacs.package}/bin/emacsclient --eval \"(mu4e-update-index)\""
[[block]] [[block]]
block = "time" block = "time"

View file

@ -1,18 +1,7 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
{ let
options.chvp.emacs = { emacsPkg = pkgs.emacsWithPackagesFromUsePackage {
enable = lib.mkOption {
default = true;
example = false;
};
};
config = lib.mkIf config.chvp.emacs.enable {
home-manager.users.charlotte = { ... }: {
programs.emacs = {
enable = true;
package = pkgs.emacsWithPackagesFromUsePackage {
config = ./emacs/init.el; config = ./emacs/init.el;
package = pkgs.emacsPgtk; package = pkgs.emacsPgtk;
alwaysEnsure = true; alwaysEnsure = true;
@ -21,12 +10,40 @@
pkgs.mu pkgs.mu
]; ];
}; };
in
{
options.chvp.emacs = {
enable = lib.mkOption {
default = true;
example = false;
};
package = lib.mkOption { };
};
config = lib.mkIf config.chvp.emacs.enable {
chvp = {
emacs.package = emacsPkg;
zfs.homeLinks = [
{ path = ".emacs.d"; type = "cache"; }
];
};
home-manager.users.charlotte = { ... }: {
services.emacs = {
enable = true;
client.enable = true;
package = emacsPkg;
}; };
home = { home = {
file = { file = {
".emacs.d/early-init.el".source = ./emacs/early-init.el; ".emacs.d/early-init.el".source = ./emacs/early-init.el;
".emacs.d/init.el".source = ./emacs/init.el; ".emacs.d/init.el".source = ./emacs/init.el;
}; };
packages = [
(pkgs.writeShellScriptBin "emacs" ''
${emacsPkg}/bin/emacsclient -c $@
'')
];
sessionVariables = { EDITOR = "emacs"; }; sessionVariables = { EDITOR = "emacs"; };
}; };
}; };

View file

@ -35,7 +35,7 @@
"hv" '(describe-variable :which-key "variable") "hv" '(describe-variable :which-key "variable")
"q" '(:ignore t :which-key "quit") "q" '(:ignore t :which-key "quit")
"qq" '(save-buffers-kill-emacs :which-key "quit") "qq" '(delete-frame :which-key "quit")
"s" '(:ignore t :which-key "search") "s" '(:ignore t :which-key "search")
@ -394,14 +394,14 @@
(setq inhibit-startup-screen t) (setq inhibit-startup-screen t)
;; Font configuration ;; Font configuration
(when window-system (set-frame-font "Fira Code 9")) (defun font-settings ()
(defun emoji-fonts () "Setup font settings."
"Setup emoji font priorities." (when window-system (set-frame-font "Fira Code 9"))
(set-fontset-font t 'symbol "Noto Color Emoji") (set-fontset-font t 'symbol "Noto Color Emoji")
(set-fontset-font t 'symbol "Symbola" nil 'append)) (set-fontset-font t 'symbol "Symbola" nil 'append))
(if (daemonp) (if (daemonp)
(add-hook 'server-after-make-frame-hook #'emoji-fonts) (add-hook 'server-after-make-frame-hook #'font-settings)
(emoji-fonts)) (font-settings))
(provide 'init) (provide 'init)
;;; init.el ends here ;;; init.el ends here