Krolyxon
Commit ff7bd95

Branches

Refs →

aurora.configquickshellauroraShot.qml

33 lines · 1.4 KB · QML

1pragma Singleton
2import QtQuick
3import 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>`.
7Singleton {
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}