Subject: [bug#56770] [PATCH] gnu: Add grimshot.

From: Antero Mejr <[email-masked]>
Date: Mon, 25 Jul 2022 16:54:12 -0400

* gnu/packages/wm.scm (grimshot): New variable.
---
 gnu/packages/wm.scm | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/gnu/packages/wm.scm b/gnu/packages/wm.scm
index 8fef7de77b..9aad6c1c37 100644
--- a/gnu/packages/wm.scm
+++ b/gnu/packages/wm.scm
@@ -2742,3 +2742,38 @@ (define-public avizo
      "Avizo is a simple notification daemon for Sway, mainly intended to be
 used for multimedia keys.")
     (license license:gpl3+)))
+
+(define-public grimshot
+  (package
+    (inherit sway)
+    (name "grimshot")
+    (build-system trivial-build-system)
+    (arguments
+     (list
+      #:modules '((guix build utils))
+      #:builder
+      #~(begin
+          (use-modules (guix build utils))
+          (copy-recursively
+           (string-append #$(package-source this-package) "/contrib") ".")
+          (substitute* "grimshot"
+            (("date ") (string-append #$coreutils "/bin/date "))
+            (("jq ") (string-append #$jq "/bin/jq "))
+            (("swaymsg ") (string-append #$sway "/bin/swaymsg "))
+            (("notify-send ") (string-append #$libnotify "/bin/notify-send "))
+            (("grim ") (string-append #$grim "/bin/grim "))
+            (("slurp ") (string-append #$slurp "/bin/slurp "))
+            (("wl-copy ") (string-append #$wl-clipboard "/bin/wl-copy ")))
+          (delete-file "grimshot.1")
+          (system
+           (string-append #$scdoc "/bin/scdoc < grimshot.1.scd > grimshot.1"))
+          (install-file "grimshot" (string-append #$output "/bin"))
+          (install-file "grimshot.1"
+                        (string-append #$output "/usr/share/man/man1")))))
+    (native-inputs (list scdoc))
+    (inputs (list coreutils grim jq libnotify sway wl-clipboard))
+    (synopsis "Screenshot utility for the Sway window manager")
+    (description "Grimshot is a screenshot utility for @code{sway}.  It provides
+an interface over @code{grim}, @code{slurp} and @code{jq}, and supports storing
+the screenshot either directly to the clipboard using @code{wl-copy} or to a
+file.")))
-- 
2.37.0