bin: Merge clipboard wrappers
This commit is contained in:
parent
6627f790da
commit
303c3ab55e
9 changed files with 108 additions and 20 deletions
11
bin/cb-clear
11
bin/cb-clear
|
|
@ -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
|
||||
29
bin/cbclear
Executable file
29
bin/cbclear
Executable file
|
|
@ -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
|
||||
17
bin/cbcopy
Executable file
17
bin/cbcopy
Executable file
|
|
@ -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
|
||||
10
bin/cbedit
Executable file
10
bin/cbedit
Executable file
|
|
@ -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
|
||||
17
bin/cbpaste
Executable file
17
bin/cbpaste
Executable file
|
|
@ -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
|
||||
22
bin/cbwatch
Executable file
22
bin/cbwatch
Executable file
|
|
@ -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
|
||||
|
|
@ -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"'
|
||||
|
|
|
|||
11
bin/wl-clear
Executable file
11
bin/wl-clear
Executable file
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue