diff --git a/bin/cb-clear b/bin/cb-clear deleted file mode 100755 index f91b53f..0000000 --- a/bin/cb-clear +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -cb_clear() { - wl-copy --foreground --clear "$@" -} - -if cb_clear --primary && cb_clear; then - notify-send -t 1000 'cb-clear' -else - notify-send -t 1000 -h 'string:bgcolor:#ff0000' 'cb-clear failed to clear' -fi diff --git a/bin/cbclear b/bin/cbclear new file mode 100755 index 0000000..186b35e --- /dev/null +++ b/bin/cbclear @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -euo pipefail + +wl_clear() { + wl-copy --foreground --clear "$@" +} + +pbclear() { + pbcopy -pboard "$1" < /dev/null +} + +OSTYPE="$(uname -s)" +case "${OSTYPE}" in + Linux) + wl_clear --primary + wl_clear + ;; + Darwin) + pbclear general + pbclear ruler + pbclear find + pbclear font + ;; + *) + >&2 echo "Unknown OS type: ${OSTYPE}" + exit 1 + ;; +esac diff --git a/bin/cbcopy b/bin/cbcopy new file mode 100755 index 0000000..dd6bb2b --- /dev/null +++ b/bin/cbcopy @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -euo pipefail + +OSTYPE="$(uname -s)" +case "${OSTYPE}" in + Linux) + exec wl-copy + ;; + Darwin) + exec pbcopy + ;; + *) + >&2 echo "Unknown OS type: ${OSTYPE}" + exit 1 + ;; +esac diff --git a/bin/cbedit b/bin/cbedit new file mode 100755 index 0000000..04a4167 --- /dev/null +++ b/bin/cbedit @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Somehow (last observed on a Mac), this pipeline ends up with a bunch of +# newlines at the end that make pasting it annoying. Use sed to remove all +# trailing newlines. +# +# https://stackoverflow.com/a/7359879/2472163 +cbpaste | vipe | sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba' | cbcopy diff --git a/bin/cbpaste b/bin/cbpaste new file mode 100755 index 0000000..db01060 --- /dev/null +++ b/bin/cbpaste @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -euo pipefail + +OSTYPE="$(uname -s)" +case "${OSTYPE}" in + Linux) + exec wl-paste --no-newline + ;; + Darwin) + exec pbpaste + ;; + *) + >&2 echo "Unknown OS type: ${OSTYPE}" + exit 1 + ;; +esac diff --git a/bin/cbwatch b/bin/cbwatch new file mode 100755 index 0000000..7464da7 --- /dev/null +++ b/bin/cbwatch @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cmd="$@" +if [ -z "$cmd" ]; then + cmd=cat +fi + +OSTYPE="$(uname -s)" +case "${OSTYPE}" in + Linux) + exec wl-paste --watch $cmd + ;; + Darwin) + >&2 echo "TODO: Make this work on macOS" + ;; + *) + >&2 echo "Unknown OS type: ${OSTYPE}" + exit 1 + ;; +esac diff --git a/bin/pbclear b/bin/pbclear index 81ca70d..3333534 100755 --- a/bin/pbclear +++ b/bin/pbclear @@ -1,12 +1,5 @@ #!/bin/sh -clear_pasteboard() { - pbcopy -pboard "$1" < /dev/null -} - -clear_pasteboard general -clear_pasteboard ruler -clear_pasteboard find -clear_pasteboard font +cbclear osascript -e 'display notification "Clipboard cleared" with title "pbclear"' diff --git a/bin/wl-clear b/bin/wl-clear new file mode 100755 index 0000000..69aedda --- /dev/null +++ b/bin/wl-clear @@ -0,0 +1,11 @@ +#!/bin/sh + +wl_clear() { + wl-copy --foreground --clear "$@" +} + +if wl_clear --primary && wl_clear; then + notify-send -t 1000 'wl-clear' +else + notify-send -t 1000 -h 'string:bgcolor:#ff0000' 'wl-clear failed to clear' +fi diff --git a/sway/config b/sway/config index f05c8d6..388d51e 100644 --- a/sway/config +++ b/sway/config @@ -177,7 +177,7 @@ focus_on_window_activation smart mouse_warping output seat seat0 hide_cursor 5000 -bindsym $super+x exec cb-clear +bindsym $super+x exec wl-clear bindsym $super+Backspace exec makoctl dismiss bindsym $super+Ctrl+Backspace exec makoctl dismiss --all