#!/bin/sh

case $1 in
{% if clipboard == 'cliphist' %}
	--menu) cliphist list | {{ launcher }} {{ dmenu_flag }} -p "Clipboard{{ (launcher == 'fuzzel') | ternary(': ', '') }}" | cliphist decode | wl-copy ;;
	--fzf) cliphist list | fzf --prompt "Clipboard " --no-multi -e | cliphist decode | wl-copy ;;

	--menu-clear) cliphist list | {{ launcher }} {{ dmenu_flag }} -p "Clear clipboard{{ (launcher == 'fuzzel') | ternary(': ', '') }}" | cliphist delete ;;
	--fzf-clear) cliphist list | fzf --prompt "Clear clipboard " -e | cliphist delete ;;
	--clear)
		wl-copy --clear
		rm -f "${XDG_CACHE_HOME:-$HOME/.cache}/cliphist/db" && \
		notify-send -u normal -t 2000 -a "Clipboard manager" \
			-i "${XDG_DATA_HOME:-$HOME/.local/share}/icons/notifications/clipboard.png" \
			"Clipboard" "History cleared" ;;
{% endif %}
	*) ;;
esac
