#!/bin/sh set -eu label=${1:-content} tmp=$(mktemp "${TMPDIR:-/tmp}/aerc-copy.XXXXXX") trap 'rm -f "$tmp"' EXIT HUP INT TERM cat >"$tmp" bytes=$(wc -c <"$tmp" | tr -d ' ') if [ "$bytes" -eq 0 ]; then notify-send -u normal "aerc" "Nothing copied: $label was empty" exit 1 fi if wl-copy --type text/plain <"$tmp"; then notify-send "aerc" "Copied $label ($bytes bytes)" else notify-send -u critical "aerc" "Copy failed: wl-copy" exit 1 fi