mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-23 01:05:38 +00:00
package ocr script with dependencies
This commit is contained in:
parent
be581dba1f
commit
3dcafb8c25
@ -1,4 +1,19 @@
|
|||||||
{ config, pkgs, lib, ... }: {
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
# Quickly package shell scripts with their dependencies
|
||||||
|
# From https://discourse.nixos.org/t/how-to-create-a-script-with-dependencies/7970/6
|
||||||
|
mkScript = { name, file, env ? [ ] }:
|
||||||
|
pkgs.writeScriptBin name ''
|
||||||
|
for i in ${lib.concatStringsSep " " env}; do
|
||||||
|
export PATH="$i/bin:$PATH"
|
||||||
|
done
|
||||||
|
|
||||||
|
exec ${pkgs.bash}/bin/bash ${file} $@
|
||||||
|
'';
|
||||||
|
|
||||||
|
in {
|
||||||
|
|
||||||
home-manager.users.${config.user} = {
|
home-manager.users.${config.user} = {
|
||||||
|
|
||||||
@ -17,9 +32,11 @@
|
|||||||
consul
|
consul
|
||||||
noti # Create notifications programmatically
|
noti # Create notifications programmatically
|
||||||
ipcalc # Make IP network calculations
|
ipcalc # Make IP network calculations
|
||||||
whois # Lookup IPs
|
(mkScript {
|
||||||
(pkgs.writeScriptBin "ocr"
|
name = "ocr";
|
||||||
(builtins.readFile ../shell/bash/scripts/ocr.sh))
|
file = ../shell/bash/scripts/ocr.sh;
|
||||||
|
env = [ tesseract ];
|
||||||
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
programs.fish.shellAbbrs = {
|
programs.fish.shellAbbrs = {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env bash
|
||||||
#!nix-shell -i bash -p tesseract
|
|
||||||
|
|
||||||
# Yoinked from https://github.com/JJGO/dotfiles
|
# Yoinked from https://github.com/JJGO/dotfiles
|
||||||
# Adapted from https://github.com/sdushantha/bin
|
# Adapted from https://github.com/sdushantha/bin
|
||||||
@ -9,13 +8,13 @@ TEXT_FILE="/tmp/ocr.txt"
|
|||||||
IMAGE_FILE="/tmp/ocr.png"
|
IMAGE_FILE="/tmp/ocr.png"
|
||||||
|
|
||||||
function notify-send() {
|
function notify-send() {
|
||||||
osascript -e "display notification \"$2\" with title \"OCR\""
|
/usr/bin/osascript -e "display notification \"$2\" with title \"OCR\""
|
||||||
}
|
}
|
||||||
|
|
||||||
PATH="/usr/local/bin/:$PATH"
|
PATH="/usr/local/bin/:$PATH"
|
||||||
|
|
||||||
# Take screenshot by selecting the area
|
# Take screenshot by selecting the area
|
||||||
screencapture -i "$IMAGE_FILE"
|
/usr/sbin/screencapture -i "$IMAGE_FILE"
|
||||||
|
|
||||||
# Get the exit code of the previous command.
|
# Get the exit code of the previous command.
|
||||||
# So in this case, it is the screenshot command. If it did not exit with an
|
# So in this case, it is the screenshot command. If it did not exit with an
|
||||||
@ -44,7 +43,7 @@ fi
|
|||||||
|
|
||||||
# Copy text to clipboard
|
# Copy text to clipboard
|
||||||
# xclip -selection clip < "$TEXT_FILE"
|
# xclip -selection clip < "$TEXT_FILE"
|
||||||
pbcopy <"$TEXT_FILE"
|
/usr/bin/pbcopy <"$TEXT_FILE"
|
||||||
|
|
||||||
# Send a notification with the text that was grabbed using OCR
|
# Send a notification with the text that was grabbed using OCR
|
||||||
notify-send "ocr" "$(cat $TEXT_FILE)"
|
notify-send "ocr" "$(cat $TEXT_FILE)"
|
||||||
|
@ -31,7 +31,7 @@ in {
|
|||||||
vimv-rs # Batch rename files
|
vimv-rs # Batch rename files
|
||||||
dig # DNS lookup
|
dig # DNS lookup
|
||||||
lf # File viewer
|
lf # File viewer
|
||||||
whois # Lookup IPs
|
# whois # Lookup IPs
|
||||||
age # Encryption
|
age # Encryption
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user