From c6dca8e82d4928ea32ad2ed34e057abe93f754ab Mon Sep 17 00:00:00 2001 From: oddlama Date: Wed, 12 Jun 2024 12:40:46 +0200 Subject: [PATCH] feat: add editing capability to screenshot tool --- pkgs/scripts/screenshot-area.nix | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/pkgs/scripts/screenshot-area.nix b/pkgs/scripts/screenshot-area.nix index f5a9f0c..2917183 100644 --- a/pkgs/scripts/screenshot-area.nix +++ b/pkgs/scripts/screenshot-area.nix @@ -2,6 +2,7 @@ writeShellApplication, grimblast, libnotify, + satty, tesseract, wl-clipboard, }: @@ -10,6 +11,7 @@ writeShellApplication { runtimeInputs = [ grimblast libnotify + satty tesseract wl-clipboard ]; @@ -17,7 +19,8 @@ writeShellApplication { umask 077 date=$(date +"%Y-%m-%dT%H:%M:%S%:z") - out="''${XDG_PICTURES_DIR-$HOME/Pictures}/screenshots/$date-selection.png" + out_base="''${XDG_PICTURES_DIR-$HOME/Pictures}/screenshots/$date-selection" + out="$out_base.png" mkdir -p "$(dirname "$out")" grimblast --freeze save area "$out" || exit 2 @@ -54,12 +57,14 @@ writeShellApplication { unset __notify_output } + edit_counter=1 title="📷 Screenshot captured" body="📋 image copied to clipboard" while true; do action=$(notify_wait_action main "$title" "$body" \ - --action=ocr="Run OCR" \ - --action=copy="Copy Image") + --action=ocr="🔠 Run OCR" \ + --action=edit="✏️ Edit" \ + --action=copy="📋 Copy Image") case "$action" in ocr) @@ -72,6 +77,18 @@ writeShellApplication { fi ;; + edit) + satty --filename "$out" \ + --output-filename "$out_base-edit-$edit_counter.png" \ + --copy-command wl-copy \ + --initial-tool brush \ + --save-after-copy \ + --fullscreen \ + --early-exit + body="🎨 image edited" + edit_counter=$((edit_counter + 1)) + ;; + copy) wl-copy -t image/png < "$out" body="📋 image copied to clipboard"