diff --git a/.config/aerc/paste-attachment.sh b/.config/aerc/paste-attachment.sh index 3715edc2..02765073 100755 --- a/.config/aerc/paste-attachment.sh +++ b/.config/aerc/paste-attachment.sh @@ -2,12 +2,11 @@ # if the clipboard is plain/text, we assume it's a path # otherwise, we assume it's a mime-type to be pasted -TYPE=$(wl-paste --list-types) -if "$TYPE" | grep -qv '^text/plain$'; then +if wl-paste --list-types | grep -qv '^text/plain$'; then # clipboard contains a file tempdir=$(mktemp -d) wl-paste >temp - extension=$(grep -E "^$TYPE" /etc/mime.types | awk '{print $2}') + extension=$(grep -E "^$(wl-paste --list-types)" /etc/mime.types | awk '{print $2}') # echo -n "File name: " >&2 # read -r user_input read -r -p "$(echo -n "Enter file name (extension .$extension will be appended): " >&2)" user_input @@ -22,15 +21,21 @@ if "$TYPE" | grep -qv '^text/plain$'; then exit 1 ;; esac -elif "$TYPE" | grep -q '^text/uri-list$' && "$TYPE" | grep -q '^file://'; then - # convert URI into standard path - echo "hola" else # clipboard contains a string (treat as path) - read -r -p "$(echo -n "Your clipboard contains $(wl-paste), which will be attached as a file path. Confirm (y/n): " >&2)" confirm + out=$(wl-paste) + if wl-paste --list-types | grep -q '^text/uri-list$' && wl-paste | grep -q '^file://'; then + echo "URI DETECT" + out=${out#file://} + fi + if [ ! -f "$out" ]; then + echo "Your clipboard does not contain a valid file or path!" >&2 + exit 1 + fi + read -r -p "$(echo -n "Your clipboard contains $out, which will be attached as a file path. Confirm (y/n): " >&2)" confirm case "$confirm" in y) - wl-paste + echo "$out" ;; *) exit 1 diff --git a/.config/aerc/temp b/.config/aerc/temp new file mode 100644 index 00000000..bb9eb10f --- /dev/null +++ b/.config/aerc/temp @@ -0,0 +1,2 @@ +file:///home/fic/Pictures/gussy.jpg +