feat: Write ocr result into clipboard
This commit is contained in:
parent
5d4965f014
commit
e73044d6f7
16
main.cpp
16
main.cpp
@ -120,6 +120,20 @@ static std::vector<unsigned char> read_clipboard() {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void write_clipboard(const std::string &text) {
|
||||||
|
const char *cmd;
|
||||||
|
if (getenv("WAYLAND_DISPLAY")) {
|
||||||
|
cmd = "wl-copy 2>/dev/null";
|
||||||
|
} else {
|
||||||
|
cmd = "xclip -selection clipboard 2>/dev/null";
|
||||||
|
}
|
||||||
|
FILE *pipe = popen(cmd, "we");
|
||||||
|
if (!pipe)
|
||||||
|
return;
|
||||||
|
fwrite(text.data(), 1, text.size(), pipe);
|
||||||
|
pclose(pipe);
|
||||||
|
}
|
||||||
|
|
||||||
static std::string capture_screenshot(bool quiet) {
|
static std::string capture_screenshot(bool quiet) {
|
||||||
const char *tmpdir = getenv("TMPDIR");
|
const char *tmpdir = getenv("TMPDIR");
|
||||||
if (!tmpdir)
|
if (!tmpdir)
|
||||||
@ -507,6 +521,8 @@ int main(int argc, char **argv) {
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
write_clipboard(ocr_text);
|
||||||
|
|
||||||
llama_batch_free(batch);
|
llama_batch_free(batch);
|
||||||
llama_sampler_free(smpl);
|
llama_sampler_free(smpl);
|
||||||
mtmd_free(ctx_vision);
|
mtmd_free(ctx_vision);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user