Ouch, I think I found a solution, but it hurts my eyes:

```
next=":0"

dd if=/dev/urandom | base64 | dd bs=1024 count=1000 > data 2>/dev/null

cat data | (
    rm tmp tmp2
    mkfifo tmp tmp2

    cat tmp | dd bs=16M iflag=fullblock count=1 | (
        if ! DISPLAY="$next" xclip -o -sel clip | diff -q - tmp2 > /dev/null; then
            echo diff
            cat | DISPLAY="$next" xclip -i -sel clip
        else
            echo same
            cat > /dev/null
        fi
    ) &
    cpid=$!

    tee tmp | dd bs=16M iflag=fullblock count=1 > tmp2

    wait $cpid
)

# Check if content identical
DISPLAY="$next" xclip -o -sel clip | diff -q -s - data
```

We always allocate 2*16MB of memory, and don't support clipboard larger than 16MB (croutonwebsocket won't accept more, anyway...).

We might be better off writing a small C wrapper around xclip... Or give up and use a temp file, which is not that bad to start with...