forked from cspeterson/splatmoji
-
Notifications
You must be signed in to change notification settings - Fork 0
/
splatmoji
executable file
·53 lines (47 loc) · 1.35 KB
/
splatmoji
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
#!/usr/bin/env bash
shopt -s nullglob
if [ "${1}" == '-h' ] || [ "${1}" == '--help' ] || [ $# -eq 0 ]; then
echo "Usage: ${0} [copy|type] [DATAFILES*]"
echo 'Quickly look up and input emoji and/or emoticons/kaomoji on your GNU/Linux desktop via pop-up menu.'
exit 0
fi
# Determine config files
scriptdir="$( cd "$( dirname "$( readlink -f "${BASH_SOURCE[0]}" )" )" && pwd )"
if [ -d "${HOME}/.config/splatmoji" ]; then
conffile="${HOME}/.config/splatmoji/splatmoji.config"
else
conffile="${scriptdir}/splatmoji.config"
fi
if [ "${1}" == 'type' ]; then
output_type='type'
elif [ "${1}" == 'copy' ]; then
output_type='copy'
fi
shift
if [ $# -eq 0 ]; then
datafiles=("${scriptdir}/data/*")
else
datafiles="${@:2}"
fi
datafiles_list=$(IFS=$'\n'; echo "${datafiles[*]}")
# Read config
declare -A config
while IFS='' read -r line; do
if [[ -z "${line}" ]] || [ "${line:0:1}" == '#' ]; then
continue
fi
key=$(echo "${line}" | cut -d '=' -f 1)
val=$(echo "${line}" | cut -d '=' -f 2)
config["${key}"]="${val}"
done < "${conffile}"
# Prompt user for selection
selection=$(cat ${datafiles_list} | ${config[rofi_command]})
moji=$(cut -f 1 <<< "$selection")
# Results to clipboard or selected x window
if [ "${output_type}" == 'type' ]; then
sleep 0.2
${config[xdotool_command]} "${moji}"
else
# Else copy
echo -n "${moji}" | ${config[xsel_command]}
fi