From ad03744781fb99cdf64f9d5537cad7e882640d4c Mon Sep 17 00:00:00 2001 From: oddlama Date: Fri, 29 Sep 2023 17:30:17 +0200 Subject: [PATCH] chore: disable tesseract OCR for fullscreen screenshots --- users/myuser/graphical/i3.nix | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/users/myuser/graphical/i3.nix b/users/myuser/graphical/i3.nix index 7db30d2..d2d37cd 100644 --- a/users/myuser/graphical/i3.nix +++ b/users/myuser/graphical/i3.nix @@ -55,8 +55,10 @@ in { + toString (pkgs.writeShellScript "screenshot-area" '' set -euo pipefail umask 077 + out="/tmp/screenshots.$UID/$(date +"%Y-%m-%dT%H:%M:%S%:z")-selection.png" mkdir -p "$(dirname "$out")" + ${pkgs.maim}/bin/maim --color=.4,.7,1 --bordersize=1.0 --nodecorations=1 --hidecursor --format=png --quality=10 --noopengl --select "$out" notification_id=$(${pkgs.libnotify}/bin/notify-send --icon="$out" --print-id --app-name "screenshot-area" "Screenshot Captured" "šŸ“‹ copied to clipboard\nāŒ› Running OCR...") ${pkgs.xclip}/bin/xclip -selection clipboard -t image/png < "$out" @@ -72,6 +74,7 @@ in { # TODO --icon=some-qr-image + toString (pkgs.writeShellScript "screenshot-area-scan-qr" '' set -euo pipefail + umask 077 # Create in-memory tmpfile TMPFILE=$(mktemp) @@ -101,16 +104,12 @@ in { + toString (pkgs.writeShellScript "screenshot-screen" '' set -euo pipefail umask 077 + out="${config.xdg.userDirs.pictures}/screenshots/$(date +"%Y-%m-%dT%H:%M:%S%:z")-fullscreen.png" mkdir -p "$(dirname "$out")" + ${pkgs.maim}/bin/maim --hidecursor --format=png --quality=10 --noopengl "$out" - notification_id=$(${pkgs.libnotify}/bin/notify-send --icon="$out" --print-id --app-name "screenshot-screen" "Screenshot Captured" "šŸ’¾ saved to $out\nāŒ› Running OCR...") - ${pkgs.tesseract}/bin/tesseract "$out" - -l eng+deu | ${pkgs.xclip}/bin/xclip -selection primary - if ${pkgs.tesseract}/bin/tesseract "$out" - -l eng+deu | ${pkgs.xclip}/bin/xclip -selection primary; then - ${pkgs.libnotify}/bin/notify-send --icon="$out" --replace-id="$notification_id" --app-name "screenshot-screen" "Screenshot Captured" "šŸ’¾ saved to $out\nāœ… OCR (copied to primary)." - else - ${pkgs.libnotify}/bin/notify-send --icon="$out" --replace-id="$notification_id" --app-name "screenshot-screen" "Screenshot Captured" "šŸ’¾ saved to $out\nāŒ Error while running OCR." - fi + notification_id=$(${pkgs.libnotify}/bin/notify-send --icon="$out" --print-id --app-name "screenshot-screen" "Screenshot Captured" "šŸ’¾ saved to $out") ''); "Shift+r" = "reload";