added dragon support to clipimg

master
Steven Saus 4 years ago
parent 868129a6f4
commit e63bc6472c
  1. 51
      clipimg.sh

@ -28,11 +28,15 @@
#does this not work for gif? #does this not work for gif?
# this does work with gifs if you have DRAGON installed:
# https://github.com/mwh/dragon
# and will preferentially use DRAGON if it is in your path
############################################################################## ##############################################################################
# Init # Init
############################################################################## ##############################################################################
EmojiPath="/home/steven/images2/emojis/" EmojiPath="/home/steven/images2/emojis/"
ReactionPath="/home/steven/images2/static_reaction/" ReactionPath="/home/steven/images2/all_reactions/"
IconPath="/home/steven/.icons/" IconPath="/home/steven/.icons/"
ClipartPath="/home/steven/documents/resources/" ClipartPath="/home/steven/documents/resources/"
FD_FIND=$(which fdfind) FD_FIND=$(which fdfind)
@ -43,6 +47,8 @@ Icon="false"
Clipart="false" Clipart="false"
CliOnly="true" CliOnly="true"
Choices="" Choices=""
DRAGON_bin=$(which dragon)
############################################################################## ##############################################################################
# Show the Help # Show the Help
@ -65,10 +71,18 @@ display_help(){
############################################################################## ##############################################################################
build_search_items() { build_search_items() {
if [ -f "$FD_FIND" ];then if [ ! -z "$DRAGON_bin" ];then
Choices+=$(fdfind -a -e png -e jpg . "$TempSearchPath") if [ -f "$FD_FIND" ];then
Choices+=$(fdfind -a -e png -e jpg -e gif . "$TempSearchPath")
else
Choices+=$(find -H "$SearchPath" -type f -iname "*.png" -or -iname "*.jpg" -or -iname "*.gif")
fi
else else
Choices+=$(find -H "$SearchPath" -type f -iname "*.png" -or -iname "*.jpg") if [ -f "$FD_FIND" ];then
Choices+=$(fdfind -a -e png -e jpg . "$TempSearchPath")
else
Choices+=$(find -H "$SearchPath" -type f -iname "*.png" -or -iname "*.jpg")
fi
fi fi
Choices+="\n" Choices+="\n"
TempSearchPath="" TempSearchPath=""
@ -157,17 +171,22 @@ build_search_items() {
############################################################################## ##############################################################################
if [ -f "$SelectedImage" ];then if [ -f "$SelectedImage" ];then
mime=$(mimetype "$SelectedImage" | awk -F ': ' '{print $2}') if [ ! -z "$DRAGON_bin" ];then
# Tee does not seem to like binary data... `$DRAGON_bin -a -x "$SelectedImage" &`
xclip -i -selection primary -t "$mime" < "$SelectedImage" > /dev/null else
xclip -i -selection clipboard -t "$mime" < "$SelectedImage" > /dev/null mime=$(mimetype "$SelectedImage" | awk -F ': ' '{print $2}')
#if you use copyq you need these lines to have it offer up the selection # Tee does not seem to like binary data...
/usr/bin/copyq write 0 "$mime" - < "$SelectedImage" xclip -i -selection primary -t "$mime" < "$SelectedImage" > /dev/null
/usr/bin/copyq select 0 xclip -i -selection clipboard -t "$mime" < "$SelectedImage" > /dev/null
#if you use copyq you need these lines to have it offer up the selection
/usr/bin/copyq write 0 "$mime" - < "$SelectedImage"
/usr/bin/copyq select 0
# putting the filename in the second position
if [ "$Icon" == "true" ] || [ "$Clipart" == "true" ];then
/usr/bin/copyq insert 1 "$SelectedImage"
/usr/bin/copyq select 0
fi
fi
fi fi
# putting the filename in the second position
if [ "$Icon" == "true" ] || [ "$Clipart" == "true" ];then
/usr/bin/copyq insert 1 "$SelectedImage"
/usr/bin/copyq select 0
fi

Loading…
Cancel
Save