awesomewm/modules/screenshot/screenshot.fish

59 lines
1.2 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 "*"
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