[okular] [Bug 173896] Sent-to menu entry or send-via-email menu-entry

via KDE Bugzilla bugzilla_noreply at kde.org
Wed Aug 31 10:55:14 UTC 2016


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

--- Comment #27 from mossl at 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 the assignee for the bug.


More information about the Okular-devel mailing list