https://bugs.kde.org/show_bug.cgi?id=173896

--- Comment #27 from mo...@gmx.net ---
assign this script to any global shortcut, and enjoy:

-------------------------------------------------
#!/bin/bash

# opens a new mail in kmail or (if installed) in thunderbird, with the selected 
# files as attachement
# modify the "lsof"-line if you want to find other files than *.pdf currently
opened by okular...

# prerequisites: zenity

# attention: the colon (,) is used as separator for multiple attachements, and
"?" might be a
# problem too
# , and ? are converted to URI (%2C resp. %3F) other troublemakers could be
solved that way too

# THIS SCRIPT WILL !!!_NOT_!!! WORK FOR FILENAMES WITH LINEBREAKS - who ever
thinks to need
# linebreaks in a filename is free to write a script of it's own ...

if [ "$(which zenity)" = "" ] ; then
        echo "zenity NOT installed, please install with: sudo apt install
zenity"
        exit 0
fi

if [ "$(which thunderbird)" != "" ] ; then
        MailModus="TB"
else
        if [ "$(which kmail)" != "" ] ; then
                MailModus="KM"
        else
                echo "Neither KMail nor Thunderbird found ... exiting!"
                exit 0
        fi
fi


AllFilesOpen=$(lsof -c okular -Fn | grep -e '.*\.pdf' | sed s/n//)

IFSORIG=$IFS
IFS="
"

FilesToProcess=$(zenity    --text="Please select file(s) to send per mail..." \
            --list --multiple --separator="$IFS" \
            --column="*.pdf-files currently open" $AllFilesOpen \
            --width=750 --height=300)

if [ "$FilesToProcess" = "" ] ; then
    exit 0
fi

for FileToEncode in $FilesToProcess
do
        if [ $(echo $FileToEncode | grep -c ",") = "1" ] ; then
                FileToEncode=$(echo "$FileToEncode" | sed 's/,/%2C/g')
        fi

        if [ $(echo $FileToEncode | grep -c "?") = "1" ] ; then
                FileToEncode=$(echo "$FileToEncode" | sed 's/\?/%3F/g')
        fi
        case $MailModus in
        "TB")
            FilesProcessed="$FilesProcessed""file://""$FileToEncode"","
            ;;
        "KM")
            FilesProcessed="$FilesProcessed"" --attach
'file://""$FileToEncode""'"
            ;;
        *)
        esac

done

FilesProcessed=$(echo $FilesProcessed | sed -e 's/,$//g')

IFS=$IFSORIG

case $MailModus in
"TB")
    thunderbird -compose "attachment='$FilesProcessed'"
    ;;
"KM")
    echo "$FilesProcessed" | xargs kmail
    ;;
*)
esac

exit 0
-------------------------------------------------

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to