diff options
-rw-r--r-- | hm/soispha/pkgs/scripts.nix | 17 | ||||
-rwxr-xr-x | hm/soispha/pkgs/scripts/apps/con2pdf | 38 |
2 files changed, 45 insertions, 10 deletions
diff --git a/hm/soispha/pkgs/scripts.nix b/hm/soispha/pkgs/scripts.nix index 4a20eb55..fa7ba7ab 100644 --- a/hm/soispha/pkgs/scripts.nix +++ b/hm/soispha/pkgs/scripts.nix @@ -21,10 +21,23 @@ path = "apps"; dependencies = builtins.attrValues {inherit (pkgs) udisks gawk gnused gnugrep sudo;}; }; - con2pdf-scr = write_script { + con2pdf-scr = sysLib.writeShellScriptWithLibrary { name = "con2pdf"; - path = "apps"; + path = ./scripts/apps/con2pdf; dependencies = builtins.attrValues {inherit (pkgs) sane-backends imagemagick coreutils fd;}; + generateCompletions = true; + replacementStrings = { + DEVICE_FUNCTION = + # This is here, because escaping the whole function, to use it in the shell script + # directly just isn't possible + pkgs.writeText "DEVICE_FUNCTION" + /* + bash + */ + '' + scanimage -L | awk 'BEGIN { FS = "`" } { gsub(/'.*/, "", $2); print $2 }' + ''; + }; }; dldragon-scr = write_script { name = "dldragon"; diff --git a/hm/soispha/pkgs/scripts/apps/con2pdf b/hm/soispha/pkgs/scripts/apps/con2pdf index 0c4ec993..550fe5e9 100755 --- a/hm/soispha/pkgs/scripts/apps/con2pdf +++ b/hm/soispha/pkgs/scripts/apps/con2pdf @@ -17,23 +17,45 @@ cat << EOF Scan images and turn them into a pdf. Usage: - $NAME [--help|--version|--out-dir|--num-pages|--method] --name --device + $NAME [OPTIONS] --name --device -Options: - --out-dir | -o +OPTIONS: + --out-dir | -o [FILE] Path to place the generated pdf files (default: ./pdf). - --name | -n - Name for the pdf files (e.g. "\$name"_1.pdf). - --num-pages | -p + + --name | -n NAME + Name for the pdf files (e.g. <NAME>_1.pdf). + + --num-pages | -p NUM Number of pages to merge into one pdf (default: 1). - --device | -d + + --device | -d DEVICE Device used for scanning. - --method | -m + + --method | -m METHOD Method to use for scanning (default: ADF). + --help | -h Display this help and exit. + --version | -v Display version and copyright information and exit. +ARGUMENTS: + FILE := [[fd .]] + A name of a file to store, default is: ./pdf + + NAME | * := [[fd .]] + The basename of the generated files + + NUM | *([0-9]) := 0 | 1 | 2 | 3 | 4 + Possible numbers of pages, can be more than 4 + + DEVICE := [[$(cat %DEVICE_FUNCTION)]] + Possible scanner names + + METHOD := ADF | Flatbed + The scanning method to use, not all scanners support both of + these. The default is ADF EOF } |