~skiqqy/bin

8e9452d6b474237ad6bf07442f276c7fb0931a96 — Stephen Cochrane 2 months ago ca2ec21
Clip is now thread safe
1 files changed, 23 insertions(+), 1 deletions(-)

M clip
M clip => clip +23 -1
@@ 22,6 22,25 @@ EOF
	exit "${1:-0}"
}

# No-Op till we get the lock, blocking
# Usage: lock [NAME] [Instr to do if lock fails, until succeed]
lock()
{
	# What op to do in the loop, allows for setting exit, ie locks failure -> prog term
	lock_op="${2:-:}"
	while ! mkdir "/tmp/todo.${1:-generic}.lock"
	do
		$lock_op
	done
}

# Release the lock
# Usage: unlock [NAME]
unlock()
{
	rm -r "/tmp/todo.${1:-generic}.lock"
}

# Select an item from the buffer to paste
paste()
{


@@ 105,7 124,10 @@ main()

	touch "$buffer"
	case "$com" in
		copy|paste|clean) $com "$@"
		copy|paste|clean)
			lock generic exit # Exit is for dwm to not repeatedly try.
			$com "$@"
			unlock generic
			;;
		'')
			usage