From d6c29481351d6e1de30055c8b50ea5abbe3f310c Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sun, 13 Aug 2023 16:19:47 +0100 Subject: [PATCH 1/2] home: zsh: add 'zsh-done' --- modules/home/zsh/default.nix | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/modules/home/zsh/default.nix b/modules/home/zsh/default.nix index 987f3b8..d983116 100644 --- a/modules/home/zsh/default.nix +++ b/modules/home/zsh/default.nix @@ -15,6 +15,16 @@ in enable = my.mkDisableOption "zsh configuration"; launchTmux = mkEnableOption "auto launch tmux at shell start"; + + notify = { + enable = mkEnableOption "zsh-done notification"; + + ssh = { + enable = mkEnableOption "notify through SSH/non-graphical connections"; + + useOsc777 = lib.my.mkDisableOption "use OSC-777 for notifications"; + }; + }; }; config = lib.mkIf cfg.enable (lib.mkMerge [ @@ -93,5 +103,35 @@ in enableVteIntegration = true; }; } + + (lib.mkIf cfg.notify.enable { + programs.zsh = { + plugins = [ + { + name = "zsh-done"; + file = "share/zsh/site-functions/done.plugin.zsh"; + src = pkgs.ambroisie.zsh-done; + } + ]; + + # `localVariables` values don't get merged correctly due to their type, + # don't use `mkIf` + localVariables = { } + # Enable `zsh-done` through SSH, if configured + // lib.optionalAttrs cfg.notify.ssh.enable { DONE_ALLOW_NONGRAPHICAL = 1; } + ; + + # Use OSC-777 to send the notification through SSH + initExtra = lib.mkIf cfg.notify.ssh.useOsc777 '' + done_send_notification() { + local exit_status="$1" + local title="$2" + local message="$3" + + ${lib.getExe pkgs.ambroisie.osc777} "$title" "$message" + } + ''; + }; + }) ]); } From c044b636e9bd74cbac9c91ea62053fcd09711a54 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 12 Feb 2024 21:22:19 +0000 Subject: [PATCH 2/2] homes: bazin: enable zsh notifications --- hosts/homes/ambroisie@bazin/default.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hosts/homes/ambroisie@bazin/default.nix b/hosts/homes/ambroisie@bazin/default.nix index a969d8a..6878e00 100644 --- a/hosts/homes/ambroisie@bazin/default.nix +++ b/hosts/homes/ambroisie@bazin/default.nix @@ -21,5 +21,17 @@ package = pkgs.emptyDirectory; }; }; + + zsh = { + notify = { + enable = true; + + ssh = { + enable = true; + + useOsc777 = false; # notify-send is proxied to the ChromeOS layer + }; + }; + }; }; }