Files
blomarchy/bin/blob-clipboard-file

34 lines
634 B
Bash
Executable File

#!/bin/bash
# blob:summary=Copy a file to the clipboard and paste it
# blob:group=clipboard
# blob:args=[--copy-only] <mime-type> <path>
# blob:examples=blob clipboard paste file image/png /tmp/screenshot.png
# blob:hidden=true
copy_only=false
if [[ ${1:-} == "--copy-only" ]]; then
copy_only=true
shift
fi
mime=${1:-}
path=${2:-}
if [[ -z $mime || -z $path ]]; then
echo "Usage: blob-clipboard-file [--copy-only] <mime-type> <path>" >&2
exit 1
fi
[[ -r $path ]] || exit 1
wl-copy --type "$mime" < "$path"
if [[ $copy_only == "true" ]]; then
exit
fi
sleep 0.15
wtype -M shift -k Insert -m shift 2>/dev/null || true