awesomewm/modules/screenshot/screenshot.fish

69 lines
1.5 KiB
Fish
Executable File

#!/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
case ocr-eng
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
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
case lpr
# Default printer must be set for the lpr command to work.
# 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
rm $tmp_file
rm $tmp_file.pdf
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