dotfiles/local/bin/ecop.sh
2025-06-15 14:44:53 +03:30

20 lines
464 B
Bash
Executable file

#!/bin/sh
tmpfile=$(mktemp)
if "$@" >"$tmpfile"; then
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
cat "$tmpfile" | wl-copy
elif [ "$XDG_SESSION_TYPE" = "x11" ]; then
cat "$tmpfile" | xclip -selection clipboard
else
echo "UNKNOWN SESSION TYPE!! >> $XDG_SESSION_TYPE" >&2
rm -f "$tmpfile"
exit 1
fi
cat "$tmpfile"
rm -f "$tmpfile"
exit 0
else
cat "$tmpfile"
rm -f "$tmpfile"
exit 1
fi