Files
glyph-synth/gui
2020-10-11 11:34:56 -06:00

46 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
if ! hash zenity 2>/dev/null; then
echo "Please install zenity."
exit 127 # command not found error
fi
if ! hash convert 2>/dev/null; then
echo "Please install imagemagic."
exit 127
fi
zen_error () {
if [ -z "$1" ]; then
zenity --error --title="ALERT! ERROR!" --text="An unknown error has occured"
exit 1 # general error
else
if [ -z "$2" ]; then
zenity --error --title="ALERT! ERROR!" --text="$1"
exit 1
else
zenity --error --title="ALERT! ERROR!" --text="$1"
exit $2
fi
fi
}
HEXGLYPH=$(zenity --entry --title="Glyph hex" --text="Enter Hex value for each glyph\n\n NOT Galactic coordinates\n\n Example: 006afa556c30\tNOT: 042f:0079:0D55:006a")
[[ "$?" != "0" ]] && zen_error "Action cancelled by user" 1
if [ -z "$HEXGLYPH" ]; then
zen_error "No data was input" 1
fi
# check if len == 12
HGLEN=${#HEXGLYPH}
if [ $HGLEN != 12 ]; then
zen_error "12 (HEX) chars are required" 1
fi
HEXGLYPH=${HEXGLYPH^^} # Make string uppercase
echo -e "Glyph code: \e[0;94m$HEXGLYPH\e[0m" # not necessary but nice to have
GC=$(bash ./converter.sh $HEXGLYPH)
echo -e "Galatic Coordinates: \e[0;94m$GC\e[0m" # not necessary but nice to have"
exit 0