2022-08-01 15:00:16 -07:00
|
|
|
#!/usr/bin/fish
|
|
|
|
#
|
|
|
|
# Screenshot wrapper
|
|
|
|
#
|
|
|
|
# Usage: ./screenshot.fish [action]
|
|
|
|
# Actions:
|
|
|
|
# Normal: regular flameshot
|
|
|
|
# Pin: flameshot fast pin
|
|
|
|
# OCR: flameshot -> tesseract -> xclip, no save.
|
|
|
|
|
|
|
|
|
|
|
|
function capture
|
|
|
|
# Screenshot save location
|
|
|
|
set dest $HOME/Screenshots/
|
|
|
|
|
|
|
|
#set tmp_file (mktemp --tmpdir "scrot-tmp-XXX.png")
|
|
|
|
set tmp_file "/tmp/screenshot-tmp.png"
|
|
|
|
|
|
|
|
switch $argv[1]
|
|
|
|
case normal
|
|
|
|
flameshot gui
|
|
|
|
|
|
|
|
case pin
|
|
|
|
flameshot gui --accept-on-select --pin
|
|
|
|
|
2022-08-02 16:43:28 -07:00
|
|
|
case ocr-eng
|
2022-08-01 15:00:16 -07:00
|
|
|
flameshot gui --accept-on-select --path $tmp_file
|
|
|
|
|
|
|
|
# Recognize text
|
|
|
|
set ocr (tesseract --dpi 96 -l eng $tmp_file stdout)
|
|
|
|
|
|
|
|
# Trim whitespace and copy to clipboard
|
|
|
|
echo $ocr | sed -e "s/^[ \t]*//" | xclip -i -rmlastnl -selection clipboard
|
|
|
|
rm $tmp_file
|
|
|
|
|
2022-08-02 16:43:28 -07:00
|
|
|
case ocr-rus
|
|
|
|
flameshot gui --accept-on-select --path $tmp_file
|
|
|
|
|
|
|
|
# Recognize text
|
|
|
|
set ocr (tesseract --dpi 96 -l rus $tmp_file stdout)
|
|
|
|
|
|
|
|
# Trim whitespace and copy to clipboard
|
|
|
|
echo $ocr | sed -e "s/^[ \t]*//" | xclip -i -rmlastnl -selection clipboard
|
|
|
|
rm $tmp_file
|
|
|
|
|
2022-08-02 19:36:59 -07:00
|
|
|
case lpr
|
|
|
|
# Default printer must be set for the lpr command to work.
|
2022-08-03 07:41:41 -07:00
|
|
|
|
2022-08-02 19:36:59 -07:00
|
|
|
# TODO: don't lpr if screenshot is cancelled.
|
|
|
|
flameshot gui --accept-on-select --path $tmp_file
|
|
|
|
convert $tmp_file $tmp_file.pdf
|
|
|
|
lpr -T "Autoprint Screenshot" $tmp_file.pdf
|
2022-08-03 18:05:24 -07:00
|
|
|
|
2022-08-02 19:36:59 -07:00
|
|
|
rm $tmp_file
|
2022-08-03 18:05:24 -07:00
|
|
|
rm $tmp_file.pdf
|
2022-08-01 15:00:16 -07:00
|
|
|
|
|
|
|
case "*"
|
|
|
|
echo "Unknown action \"$argv[1]\""
|
|
|
|
echo ""
|
|
|
|
echo "Usage: screenshot.fish [action]"
|
|
|
|
echo " Valid actions: normal, pin, ocr"
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
|
|
|
|
capture $argv
|