Commit 20c549a
Changed files (1)
modules
desktop
app
script-tools
modules/desktop/app/script-tools/ocr.nix
@@ -1,25 +1,17 @@
{
den.aspects.desktop.app.script-tools.ocr = {
hjem = {pkgs, ...}: let
- ix-ocr-script = pkgs.callPackage ({
- writeShellApplication,
- coreutils,
- grim,
- libnotify,
- slurp,
- tesseract,
- wl-clipboard-rs,
- languages ? "eng+chi_sim+chi_tra",
- psm ? "6",
- }: (writeShellApplication {
+ languages = "eng+chi_sim+chi_tra";
+
+ ix-ocr-script = pkgs.writeShellApplication {
name = "ix-ocr";
runtimeInputs = [
- coreutils
- grim
- libnotify
- slurp
- tesseract
- wl-clipboard-rs
+ pkgs.coreutils
+ pkgs.grim
+ pkgs.libnotify
+ pkgs.slurp
+ pkgs.tesseract
+ pkgs.wl-clipboard-rs
];
text = ''
geom="$(slurp -d)" || exit 0
@@ -32,7 +24,7 @@
exit 1
}
- text="$(tesseract "$img" stdout -l ${languages} --psm ${psm} 2>/dev/null)" || {
+ text="$(tesseract "$img" stdout -l ${languages} --psm 6 2>/dev/null)" || {
notify-send -u critical "OCR" "Text recognition failed (tesseract)"
exit 1
}
@@ -45,8 +37,9 @@
printf '%s' "$text" | wl-copy
printf '%s\n' "$text"
'';
+
meta.mainProgram = "ix-ocr";
- })) {};
+ };
ix-ocr-desktop-entry = pkgs.makeDesktopItem {
name = "ix-ocr";
@@ -62,12 +55,12 @@
ix-ocr = pkgs.stdenv.mkDerivation rec {
name = "ix-ocr";
- buildCommand = let
- in ''
+ buildCommand = ''
mkdir -p $out/bin
- cp ${ix-ocr-script}/bin/${name} $out/bin
+ install -Dm755 ${ix-ocr-script}/bin/${name} $out/bin/${name}
mkdir -p $out/share/applications
- cp ${ix-ocr-desktop-entry}/share/applications/${name}.desktop $out/share/applications/${name}.desktop
+ install -Dm644 ${ix-ocr-desktop-entry}/share/applications/${name}.desktop \
+ $out/share/applications/${name}.desktop
'';
dontBuild = true;
};