Skip to content

Instantly share code, notes, and snippets.

@ecliptik
Created September 30, 2022 22:04
Show Gist options
  • Save ecliptik/03e720341efa786e4e53e6b1f9ca2651 to your computer and use it in GitHub Desktop.
Save ecliptik/03e720341efa786e4e53e6b1f9ca2651 to your computer and use it in GitHub Desktop.
Genreate emoji pack for Pleroma
#!/bin/sh
#Run within a directory containing emoji to add to Pleroma
#Directoutput to `pack.json`
#Get files
files=$(ls *.png)
numfiles=$(echo ${files} | sed -e "s/ /\n/g" | wc -l | sed -e "s/ //g")
#Prepend JSON header
cat << _EOF
{
"files": {
_EOF
#Loop through and create emoji list
count=${numfiles}
for file in ${files}; do
emoji=$(echo ${file} | awk -F. '{print $1}')
#don't add a , if last element
if [ ${count} -gt 1 ]
then
echo " ${emoji}: ${file},"
else
echo " ${emoji}: ${file}"
fi
let count--
done
#Append JSON footer
cat << _EOF
},
"pack": {},
"files_count": ${numfiles}
}
_EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment