summary refs log tree commit diff
path: root/pkgs/shells/bash
diff options
context:
space:
mode:
authorKira Bruneau <kira.bruneau@pm.me>2021-04-26 16:06:02 -0400
committerKira Bruneau <kira.bruneau@pm.me>2021-04-30 09:49:05 -0400
commit2008b4f9f4507b8521a7e595235c848d96301232 (patch)
treedd1544ce3710310bc24a2a363359fb35c21defe8 /pkgs/shells/bash
parent7fe184a14a4ad4f0594c9b5ca8c7d0ac7c351296 (diff)
downloadnixpkgs-2008b4f9f4507b8521a7e595235c848d96301232.tar
nixpkgs-2008b4f9f4507b8521a7e595235c848d96301232.tar.gz
nixpkgs-2008b4f9f4507b8521a7e595235c848d96301232.tar.bz2
nixpkgs-2008b4f9f4507b8521a7e595235c848d96301232.tar.lz
nixpkgs-2008b4f9f4507b8521a7e595235c848d96301232.tar.xz
nixpkgs-2008b4f9f4507b8521a7e595235c848d96301232.tar.zst
nixpkgs-2008b4f9f4507b8521a7e595235c848d96301232.zip
undistract-me: init at unstable-2020-08-09
Diffstat (limited to 'pkgs/shells/bash')
-rw-r--r--pkgs/shells/bash/undistract-me/default.nix79
1 files changed, 79 insertions, 0 deletions
diff --git a/pkgs/shells/bash/undistract-me/default.nix b/pkgs/shells/bash/undistract-me/default.nix
new file mode 100644
index 00000000000..e6641d9039c
--- /dev/null
+++ b/pkgs/shells/bash/undistract-me/default.nix
@@ -0,0 +1,79 @@
+{ lib
+, stdenvNoCC
+, fetchFromGitHub
+, fetchpatch
+, coreutils
+, gnused
+, libnotify
+, pulseaudio
+, sound-theme-freedesktop
+, xprop
+}:
+
+stdenvNoCC.mkDerivation rec {
+  pname = "undistract-me";
+  version = "unstable-2020-08-09";
+
+  src = fetchFromGitHub {
+    owner = "jml";
+    repo = pname;
+    rev = "2f8ac25c6ad8efcf160d2b480825b1cbb6772aab";
+    hash = "sha256-Qw7Cu9q0ZgK/RTvyDdHM5N3eBaKjtYqYH0J+hKMUZX8=";
+  };
+
+  patches = [
+    # Don't block the terminal when notification sound is played
+    #
+    # See https://github.com/jml/undistract-me/pull/69
+    (fetchpatch {
+      url = "https://github.com/jml/undistract-me/commit/2356ebbe8bf2bcb4b95af1ae2bcdc786ce7cc6e8.patch";
+      sha256 = "sha256-Ij3OXTOnIQsYhKVmqjChhN1q4ASZ7waOkfQTTp5XfPo=";
+    })
+
+    # Fix showing notifications when using Wayland apps with XWayland
+    # running, or connection to X server fails.
+    #
+    # NOTE: Without a real X server, notifications will not be
+    # suppressed when the window running the command is focused.
+    #
+    # See https://github.com/jml/undistract-me/pull/71
+    (fetchpatch {
+      url = "https://github.com/jml/undistract-me/commit/3f4ceaf5a4eba8e3cb02236c48247f87e3d1124f.patch";
+      sha256 = "sha256-9AK9Jp3TXJ75Y+jwZXlwQ6j54FW1rOBddoktrm0VX68=";
+    })
+  ];
+
+  # Patch in dependencies. Can't use makeWrapper because the bash
+  # functions will be sourced and invoked in a different environment
+  # for each command invocation.
+  postPatch = ''
+    for script in *.bash *.sh; do
+      substituteInPlace "$script" \
+        --replace /usr/share/undistract-me "$out/share/undistract-me" \
+        --replace basename ${coreutils}/bin/basename \
+        --replace 'cut ' '${coreutils}/bin/cut ' \
+        --replace date ${coreutils}/bin/date \
+        --replace dirname ${coreutils}/bin/dirname \
+        --replace sed ${gnused}/bin/sed \
+        --replace notify-send ${libnotify}/bin/notify-send \
+        --replace paplay ${pulseaudio}/bin/paplay \
+        --replace /usr/share/sounds/freedesktop ${sound-theme-freedesktop}/share/sounds/freedesktop \
+        --replace xprop ${xprop}/bin/xprop
+    done
+  '';
+
+  installPhase = ''
+    mkdir -p "$out/share/undistract-me" "$out/etc/profile.d" "$out/share/licenses/undistract-me"
+    cp long-running.bash "$out/share/undistract-me"
+    cp preexec.bash "$out/share/undistract-me"
+    cp undistract-me.sh "$out/etc/profile.d"
+    cp LICENSE "$out/share/licenses/undistract-me"
+  '';
+
+  meta = with lib; {
+    description = "Notifies you when long-running terminal commands complete";
+    homepage = "https://github.com/jml/undistract-me";
+    license = licenses.mit;
+    maintainers = with maintainers; [ metadark ];
+  };
+}