~earboxer/dotfiles

dotfiles/.config/sxmo/userscripts/emojis.sh -rwxr-xr-x 1.5 KiB
0a6a1495Zach DeCook sxmo sway: Make closer to the default one 7 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh

# http://www.unicode.org/Public/emoji/14.0/emoji-test.txt
# alpine package unicode-character-database installs this here:
input=/usr/share/unicode/emoji/emoji-test.txt

topmenu(){
	menu=$(grep ' group: ' "$input" | cut -d: -f2 |sed 's/^ //g'|awk 'BEGIN{print "All Emojis"}(1){print}END{print "exit"}'| sxmo_dmenu.sh -i -p Emojis)
	case "$menu" in
	"exit" | "")
		exit;;
	"All Emojis" )
		emojis;;
	* )
		submenu "$menu";;
	esac
}
submenu(){
	menu="$1"
	submenu=$(grep group: "$input" |awk "BEGIN{print \"*\n..\"}
		/ group:/{
			if (pr){pr=0; exit}
		}
		(pr){print}
		/ group: $menu/{pr=1}
		END{print \"exit\"}
		" |cut -d: -f2|sed 's/^ //g'|sxmo_dmenu.sh -i -p "$menu")
	case "$submenu" in
	"exit" | "" )
		exit;;
	".." )
		topmenu;;
	"*" )
		emojis "$menu";;
	* )
		emojis "$menu" "$submenu";;
	esac
}
emojis(){
	menu="$1"
	submenu="$2"
	start="group:"
	end="# Status Counts"
	if test "$submenu"; then
		start="subgroup: $submenu"
		end="group:"
	elif test "$menu"; then
		start=" group: $menu"
		end=" group:"
	fi
	emoji=$(awk "BEGIN{print \"..\"}
	/$end/{
		if (pr){pr=0; exit}
	}
	(pr){print}
	/$start/{pr=1}
	END{print \"exit\"}
	" < $input | cut -d'#' -f2 | grep . | grep -v 'subtotal:' | grep -v 'group:' | sed 's/E\d\+.\d\+ *//g' | sed 's/^ //g' | sxmo_dmenu.sh -i -p "${submenu:-${menu:-All Emojis}}"| cut -d' ' -f1)
	case "$emoji" in
	"exit" | "" )
		exit;;
	".." )
		if test "$menu"; then
			submenu "$menu"
		else
			topmenu
		fi
		;;
	* )
		sxmo_type.sh "$emoji" &
		emojis "$menu" "$submenu"
		;;
	esac
}

topmenu