#!/bin/sh
#
# https://github.com/arp242/uni
#
# Usage:
#
#   dmenu-uni all            All codepoints, won't include ZWJ emoji sequences.
#   dmenu-uni emoji          All emojis.
#   dmenu-uni emoji-common   Common emojis
#
# NOTE: dmenu will *crash* when using a colour emoji font, this is a bug in Xft:
# https://bugs.freedesktop.org/show_bug.cgi?id=107534

# Command to use:
dmenu="dmenu -i"

# Or adding some options:
#dmenu="dmenu -x -i -l 20 -fn monospace:size=20 -sb #dddddd -sf #000000"

# Use Rofi instead:
#dmenu="rofi -dmenu"

# Command to copy to clipboard:
copy="xclip -rmlastnl -selection clipboard"

# Common emojis I use >99% of the time:
common="-groups smileys,hand-fingers-open,hand-fingers-partial,hand-single-finger,hand-fingers-closed,hands,body-parts,person-gesture"

# Only include gender-neutral "person":
#common="$common -gender person"

# Set skin tone:
#common="$common -tone mediumdark"

case "${1:-all}" in
	# List all codepoints.
	all)
		uni -q p all |
			$dmenu |
			grep -o "^'.'" |
			tr -d "'" |
			$copy
		;;

	# List all emojis.
	emoji)
		uni -q e all |
			$dmenu |
			cut -d' ' -f1 |
			$copy
		;;

	# List common facial expressions, excluding flags, guitars, lobsters, map of
	# Japan, and what-have-you.
	emoji-common)
		uni -q e $common | 
			$dmenu |
			cut -d' ' -f1 |
			$copy
		;;

	*)
		echo >&2 "dmenu-uni: unknown '$1'"
		;;
esac
