dotfiles/_desktop/clipboard/primary/run

22 lines
561 B
Plaintext
Raw Normal View History

2021-10-07 22:54:37 +02:00
#!/bin/sh
set -e
exec 2>&1
SEL="../selection"
# "xsel --nodetach --input" with an empty input will still exit immediately,
# so we need to make sure the selection never is empty:
[ -s "$SEL" ] || echo >| "$SEL"
xsel --nodetach --logfile /dev/stdout --"$(basename "`pwd`")" \
--input < "$SEL"
# something else grabbed the selection. pull it over here:
xsel --nodetach --logfile /dev/stdout --"$(basename "`pwd`")" \
--output > "$SEL".new
# see above:
[ -s "$SEL" ] || echo >| "$SEL"
mv "$SEL".new "$SEL"
sv term ../primary ../secondary ../clipboard