| 1 | pragma Singleton |
| 2 | import QtQuick |
| 3 | import Quickshell |
| 4 | |
| 5 | // Screenshots, ported from your fuzzel script. Needs: hyprshot (+ grim, slurp), and for |
| 6 | // OCR: tesseract + wl-clipboard. Used by the Home tab and by `ipc call shell shot <mode>`. |
| 7 | Singleton { |
| 8 | id: root |
| 9 | |
| 10 | property bool save: false // false = clipboard, true = file |
| 11 | property string dir: Quickshell.env("HOME") + "/pix/ss" // where "save" puts files |
| 12 | property string ocrLang: "eng" |
| 13 | |
| 14 | readonly property var names: ({ region: "selected", window: "window", output: "full" }) |
| 15 | |
| 16 | // mode: "region" | "window" | "output" | "ocr" |
| 17 | function take(mode) { |
| 18 | var script |
| 19 | if (mode === "ocr") { |
| 20 | script = 'slurp | grim -g - - | tesseract stdin stdout -l "$2" | wl-copy' |
| 21 | + ' && notify-send -a screenshot "OCR" "text copied to clipboard"' |
| 22 | } else if (names[mode] === undefined) { |
| 23 | return |
| 24 | } else if (!save) { |
| 25 | script = 'hyprshot -m ' + mode + ' --clipboard-only' |
| 26 | } else { |
| 27 | script = 'mkdir -p "$1"; hyprshot -m ' + mode + ' -o "$1"' |
| 28 | + ' -f "pic-' + names[mode] + '-$(date +%y-%m-%d_%H%M%S).png"' |
| 29 | } |
| 30 | // short delay so the panel is gone before the capture starts |
| 31 | Quickshell.execDetached(["sh", "-c", "sleep 0.35; " + script, "sh", dir, ocrLang]) |
| 32 | } |
| 33 | } |