1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-10 23:00:39 +02:00

feat: add editing capability to screenshot tool

This commit is contained in:
oddlama 2024-06-12 12:40:46 +02:00
parent cf56c2ea31
commit c6dca8e82d
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A

View file

@ -2,6 +2,7 @@
writeShellApplication, writeShellApplication,
grimblast, grimblast,
libnotify, libnotify,
satty,
tesseract, tesseract,
wl-clipboard, wl-clipboard,
}: }:
@ -10,6 +11,7 @@ writeShellApplication {
runtimeInputs = [ runtimeInputs = [
grimblast grimblast
libnotify libnotify
satty
tesseract tesseract
wl-clipboard wl-clipboard
]; ];
@ -17,7 +19,8 @@ writeShellApplication {
umask 077 umask 077
date=$(date +"%Y-%m-%dT%H:%M:%S%:z") 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")" mkdir -p "$(dirname "$out")"
grimblast --freeze save area "$out" || exit 2 grimblast --freeze save area "$out" || exit 2
@ -54,12 +57,14 @@ writeShellApplication {
unset __notify_output unset __notify_output
} }
edit_counter=1
title="📷 Screenshot captured" title="📷 Screenshot captured"
body="📋 image copied to clipboard" body="📋 image copied to clipboard"
while true; do while true; do
action=$(notify_wait_action main "$title" "$body" \ action=$(notify_wait_action main "$title" "$body" \
--action=ocr="Run OCR" \ --action=ocr="🔠 Run OCR" \
--action=copy="Copy Image") --action=edit=" Edit" \
--action=copy="📋 Copy Image")
case "$action" in case "$action" in
ocr) ocr)
@ -72,6 +77,18 @@ writeShellApplication {
fi 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) copy)
wl-copy -t image/png < "$out" wl-copy -t image/png < "$out"
body="📋 image copied to clipboard" body="📋 image copied to clipboard"