AutoYADM commit: 2025-03-17 13:00:06

This commit is contained in:
Daniel Fichtinger 2025-03-17 13:00:06 -04:00
parent 68191b42ef
commit e59a96b6e5
2 changed files with 30 additions and 10 deletions

View file

@ -6,13 +6,33 @@
# if the clipboard is plain/text, we assume it's a path
# otherwise, we assume it's a mime-type to be pasted
if wl-paste --list-types | grep -qv '^text/plain$'; then
notify-send "Non-text type."
temp=$(mktemp)
wl-paste > temp
grep -E "^$(wl-paste --list-types)" /etc/mime.types | awk '{print $2}'
# echo "$temp"
notify-send "Non-text type."
tempdir=$(mktemp -d)
wl-paste >temp
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
attachment="$tempdir/$user_input.$extension"
read -r -p "$(echo -n "Your file will be written to $attachment and attached. Confirm (y/n): " >&2)" confirm
case "$confirm" in
y)
wl-paste >"$attachment"
echo "$attachment"
;;
*)
exit 1
;;
esac
else
notify-send "Text type."
read -r -p "$(echo -n "Your clipboard contains $(wl-paste), which will be attached as a file path. Confirm (y/n): " >&2)" confirm
case "$confirm" in
y)
wl-paste
;;
*)
exit 1
;;
esac
fi