normcap-translate

This commit is contained in:
2026-08-05 03:56:16 +09:00
parent eff32fddcd
commit 33e09f8e93
7 changed files with 65 additions and 7 deletions
Generated
+6 -6
View File
@@ -663,17 +663,17 @@
"nixpkgs": "nixpkgs_5" "nixpkgs": "nixpkgs_5"
}, },
"locked": { "locked": {
"lastModified": 1785856454, "lastModified": 1785857772,
"narHash": "sha256-7f2AfONkRN5XpCUjN0TAO1Qlk/YImDCM28vDcC1mppI=", "narHash": "sha256-JMEQH9x8Pb9cHW4JbWfFBcqxsh4JkPDR5k8dCnphUTU=",
"ref": "refs/heads/main", "ref": "refs/heads/main",
"rev": "e0e919b6cc4eab40afe02f4ed72b93ed383674db", "rev": "9d6fec627a620841c27c7e67e8e7b5719ce9b465",
"revCount": 6, "revCount": 8,
"type": "git", "type": "git",
"url": "https://github.com/zunoser/nani-translate-linux-mirror.git" "url": "https://github.com/zunoser/nani-translate-linux.git"
}, },
"original": { "original": {
"type": "git", "type": "git",
"url": "https://github.com/zunoser/nani-translate-linux-mirror.git" "url": "https://github.com/zunoser/nani-translate-linux.git"
} }
}, },
"niri-flake": { "niri-flake": {
+1 -1
View File
@@ -111,7 +111,7 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
nani-translate-linux.url = "git+https://github.com/zunoser/nani-translate-linux-mirror.git"; nani-translate-linux.url = "git+https://github.com/zunoser/nani-translate-linux.git";
}; };
+1
View File
@@ -125,6 +125,7 @@ in
(execute "W-l" "loginctl lock-session") (execute "W-l" "loginctl lock-session")
(execute "W-v" "vicinae vicinae://launch/clipboard/history?toggle=true") (execute "W-v" "vicinae vicinae://launch/clipboard/history?toggle=true")
(execute "W-j" "nani-translate-primary") (execute "W-j" "nani-translate-primary")
(execute "W-S-j" "normcap-translate")
(execute "W-C-j" "${lib.getExe' pkgs.xdg-utils "xdg-open"} naniapp://translate") (execute "W-C-j" "${lib.getExe' pkgs.xdg-utils "xdg-open"} naniapp://translate")
(execute "W-space" "ghostty +toggle-quick-terminal") (execute "W-space" "ghostty +toggle-quick-terminal")
(execute "W-p" "wdisplays") (execute "W-p" "wdisplays")
+5
View File
@@ -117,6 +117,11 @@ in
action.spawn = [ "nani-translate-primary" ]; action.spawn = [ "nani-translate-primary" ];
hotkey-overlay.title = "Translate Primary Selection"; hotkey-overlay.title = "Translate Primary Selection";
}; };
"Mod+Shift+J" = {
repeat = false;
action.spawn = [ "normcap-translate" ];
hotkey-overlay.title = "OCR and Translate with Nani";
};
"Mod+Ctrl+J" = { "Mod+Ctrl+J" = {
repeat = false; repeat = false;
action.spawn = [ action.spawn = [
@@ -0,0 +1,44 @@
{ pkgs, ... }:
let
normcap = pkgs.normcap.override {
tesseract4 = pkgs.tesseract4.override {
enableLanguages = [
"chi_sim"
"jpn"
"eng"
];
};
};
normcapTranslate = pkgs.writeShellApplication {
name = "normcap-translate";
runtimeInputs = [
normcap
pkgs.jq
pkgs.xdg-utils
];
text = ''
captured_text="$(
normcap \
--cli-mode \
--screenshot-handler grim \
--show-introduction False \
--update False \
--detect-codes False \
--notification False \
-l jpn eng chi_sim
)" || exit 0
[ -n "$captured_text" ] || exit 0
encoded_text="$(printf '%s' "$captured_text" | jq -sRr @uri)"
exec xdg-open "naniapp://translate?source=$encoded_text"
'';
};
in
{
home.packages = [
normcap
normcapTranslate
];
}
+7
View File
@@ -0,0 +1,7 @@
{
description = "NormCap OCR screen capture";
includes = [
"applications.nani"
];
}
@@ -13,6 +13,7 @@
"applications.loupe" "applications.loupe"
"applications.linux-wallpaperengine" "applications.linux-wallpaperengine"
"applications.nautilus" "applications.nautilus"
"applications.normcap"
"applications.papers" "applications.papers"
"applications.qalculate-gtk" "applications.qalculate-gtk"
"applications.resources" "applications.resources"