diff --git a/src/dot_config/tmux/tmux.conf b/src/dot_config/tmux/tmux.conf index 843cb5b..4cdc6b9 100644 --- a/src/dot_config/tmux/tmux.conf +++ b/src/dot_config/tmux/tmux.conf @@ -87,4 +87,4 @@ bind -n C-M-n newpanecurdir bind -T copy-mode-vi v send -X begin-selection bind -T copy-mode-vi V send -X select-line -bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'cb.sh set' +bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'cb set' diff --git a/src/dot_local/bin/deskutils/executable_clipedit.sh b/src/dot_local/bin/deskutils/executable_clipedit.sh index 82754dd..8216550 100644 --- a/src/dot_local/bin/deskutils/executable_clipedit.sh +++ b/src/dot_local/bin/deskutils/executable_clipedit.sh @@ -3,7 +3,7 @@ TMPFILE="$(mktemp)" -xsel -b > "$TMPFILE" +cb > "$TMPFILE" newterm() { alacritty msg create-window "$@" || @@ -15,4 +15,4 @@ newterm \ -o 'window.opacity = 1.0' \ -o 'window.dimensions = { columns = 84, lines = 10 }' \ -o 'window.position = { x = 0, y = 1200 }' \ - -e sh -c "xsel -b > '$TMPFILE'; nvim -c 'set binary noeol textwidth=80' '$TMPFILE' && cat '$TMPFILE' | xsel -ib && rm '$TMPFILE'" + -e sh -c "cb > '$TMPFILE'; nvim -c 'set binary noeol textwidth=80' '$TMPFILE' && cat '$TMPFILE' | cb set && rm '$TMPFILE'" diff --git a/src/dot_local/bin/executable_bookmk b/src/dot_local/bin/executable_bookmk index f22fea7..63b6d8c 100644 --- a/src/dot_local/bin/executable_bookmk +++ b/src/dot_local/bin/executable_bookmk @@ -1,8 +1,8 @@ #!/bin/sh # Copy a bookmark to clipboard. # -# Requires fzf, xsel -# Bookmarks are stored in ~/dox/not/bk.txt, commented with # +# Requires fzf, cb (script in this repo) +# Bookmarks are stored in ~/dox/not/bk.txt, commented with ^ # -o: print to stdout # -b: open in browser @@ -26,7 +26,7 @@ if [ "$action" = "stdout" ]; then printf "%s" "$output" fi if [ "$action" = "clip" ]; then - printf "%s" "$output" | xsel -ib + printf "%s" "$output" | cb set fi if [ "$action" = "browser" ]; then $BROWSER "$output" diff --git a/src/dot_local/bin/executable_cb b/src/dot_local/bin/executable_cb new file mode 100644 index 0000000..202f1c5 --- /dev/null +++ b/src/dot_local/bin/executable_cb @@ -0,0 +1,45 @@ +#!/bin/sh +# cross-platform clipboard wrapper +# drop-in replacement for xsel wherever used in my dotfiles + +err () { + echo $@ 1>&2 +} + +no_provider () { + err "no providers for clipboard found!" + err "supported: termux-api, xsel, wl-clipboard" +} + +if [ -z "$1" ] || [ "$1" = "-b" ]; then + if [ -n "$WAYLAND_DISPLAY" ]; then + if command -v wl-paste > /dev/null; then + wl-paste + fi + else + if command -v xsel > /dev/null; then + xsel -b + elif command -v termux-clipboard-set > /dev/null; then + termux-clipboard-get + else + no_provider + fi + fi +elif [ "$1" = "-i" ] || [ "$1" = "set" ]; then + if [ -n "$WAYLAND_DISPLAY" ]; then + if command -v wl-copy > /dev/null; then + wl-copy + fi + else + if command -v xsel > /dev/null; then + xsel -ib + elif command -v termux-clipboard-set > /dev/null; then + cat /dev/stdin | termux-clipboard-set + else + no_provider + fi + fi +else + err "usage: cb [-i] [set] [--help]" + err "communicates via stdout/stdin." +fi diff --git a/src/dot_local/bin/executable_cb.sh b/src/dot_local/bin/executable_cb.sh deleted file mode 100644 index 3680e6a..0000000 --- a/src/dot_local/bin/executable_cb.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# clipboard wrapper - -no_provider () { - echo "no providers for clipboard found!" - echo "supported: termux-api, xsel, xclip" -} - -if [ "$1" = "set" ]; then - if command -v xsel > /dev/null; then - xsel -ib - elif command -v termux-clipboard-set > /dev/null; then - cat /dev/stdin | termux-clipboard-set - else - no_provider - fi -elif [ "$1" = "get" ]; then - if command -v xsel > /dev/null; then - xsel -b - elif command -v termux-clipboard-set > /dev/null; then - termux-clipboard-get - else - no_provider - fi -else - echo "usage: cb.sh get/set" - echo "pipe in data" -fi diff --git a/src/dot_local/bin/executable_mpvq b/src/dot_local/bin/executable_mpvq index 69edc6e..ecae538 100644 --- a/src/dot_local/bin/executable_mpvq +++ b/src/dot_local/bin/executable_mpvq @@ -2,7 +2,7 @@ # Append link from clipboard/argument to mpv playlist if [ -z "$2" ]; then - path="$(xsel -b)" + path="$(cb)" else path="$2" fi