Starts work on ActOnLast
This is a script that provides context menus (via rofi) based on a previous action. It takes an optional --first argument that, when present, causes the script to select the first option on the list automatically. It currently has two actions that it knows how to follow: * using my password manager script to select a password - In this situation it will get a otp for the same password * After taking a screenshot - open the screenshot - Add a shadow to the screenshot - Perform ocr on the screenshot I will extend this to do more things in time.
This commit is contained in:
parent
8ea14abe9e
commit
e325e49959
3 changed files with 129 additions and 31 deletions
|
@ -11,9 +11,11 @@
|
|||
# Relies on maim for taking screenshot
|
||||
# If you give it the -o flag for ocr, it needs tesseract
|
||||
|
||||
|
||||
path='/tmp'
|
||||
command -v maim > /dev/null && screenshooter="maim" || ( echo -n "You need to install maim\nhttps://github.com/naelstrof/maim" && exit 1 )
|
||||
ocr="false"
|
||||
lastactionfile="${XDG_DATA_HOME:-$HOME/.local/share}/lastaction"
|
||||
|
||||
#If a project is set we will put screenshots in the project's folder
|
||||
command -v project > /dev/null && project=$(project current --path)
|
||||
|
@ -29,7 +31,7 @@ file="${path}/${filename}"
|
|||
[ "$1" = "-w" ] && sleep "$2" && shift && shift
|
||||
[ "$1" = "-o" ] && ocr="true" && shift
|
||||
|
||||
case $1 in
|
||||
case "$1" in
|
||||
"window")
|
||||
if [ -n "$WAYLAND_DISPLAY" ]; then
|
||||
notify-send "Can't get current window yet in wayland"
|
||||
|
@ -54,36 +56,21 @@ case $1 in
|
|||
;;
|
||||
esac
|
||||
|
||||
if [ -f "$file" ]; then
|
||||
if [ "$ocr" == "true" ]; then
|
||||
# Input and output files look the same because tesseract adds .txt to whatever we give as the output file
|
||||
|
||||
tesseract "$file" "$file"
|
||||
LINES=$(wc -l < "${file}.txt")
|
||||
if [ "$LINES" -eq 0 ]; then
|
||||
notify-send "ocr" "no text was detected\nimage file at $file"
|
||||
exit 1
|
||||
fi
|
||||
if [ -n "$WAYLAND_DISPLAY" ]; then
|
||||
cat "${file}.txt" | wl-copy
|
||||
echo -n "${file}.txt" | wl-copy --primary
|
||||
else
|
||||
cat "${file}.txt" | xclip -selection clipboard
|
||||
echo -n "${file}.txt" | xclip -selection primary
|
||||
fi
|
||||
|
||||
if [ -f "$file" ]; then
|
||||
if [ -n "$WAYLAND_DISPLAY" ]; then
|
||||
# Copies the image to your clipboard (ctrl + v)
|
||||
wl-copy < "$file"
|
||||
# Copies the filename to primary selection (shift + insert or middle mouse)
|
||||
echo -n "$file" | wl-copy --primary
|
||||
else
|
||||
if [ -n "$WAYLAND_DISPLAY" ]; then
|
||||
# Copies the image to your clipboard (ctrl + v)
|
||||
wl-copy < "$file"
|
||||
# Copies the filename to primary selection (shift + insert or middle mouse)
|
||||
echo -n "$file" | wl-copy --primary
|
||||
else
|
||||
# Copies the image to your clipboard (ctrl + v)
|
||||
xclip -selection clipboard -target image/png -i "$file"
|
||||
# Copies the filename to primary selection (shift + insert or middle mouse)
|
||||
echo -n "$file" | xclip -selection primary
|
||||
fi
|
||||
# Creates notification with file name
|
||||
notify-send "New Screenshot" "$file"
|
||||
# Copies the image to your clipboard (ctrl + v)
|
||||
xclip -selection clipboard -target image/png -i "$file"
|
||||
# Copies the filename to primary selection (shift + insert or middle mouse)
|
||||
echo -n "$file" | xclip -selection primary
|
||||
fi
|
||||
# Creates notification with file name
|
||||
notify-send "New Screenshot" "$file"
|
||||
echo "screenshot $file" > "$lastactionfile"
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue