#!/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 # Make string uppercase HEXGLYPH=${HEXGLYPH^^} echo -e "Glyph code: \e[0;94m$HEXGLYPH\e[0m" # not necessary but nice to have CHOICE=$(zenity --list --checklist --title="Options" --text="Options" --column="Use" --column="Feature" TRUE "Banner" False "Translator") OPTS=$(echo $CHOICE | tr "|" "\n") for OP in $OPTS do if [ "$OP" == "Banner" ]; then BANNER=1 elif [ "$OP" == "Translator" ]; then GC=$(bash ./converter.sh $HEXGLYPH) echo -e "Galatic Coordinates: \e[0;94m$GC\e[0m" # not necessary but nice to have" zenity --info --text "Galatic Coordinates:\n\n$GC" --width=300 --height=55 fi done if [ "$BANNER" == 1 ]; then SIZE=$(zenity --list --text "Select image size" --radiolist --column "Select" --column "Size" TRUE 3072x256 FALSE 1536x126 FALSE 768x64 FALSE 384x32 FALSE 192x16) FILENAME=$(zenity --forms --title="Save" --text="Planet name" --add-entry="") bash -c "./genimg.sh $HEXGLYPH $SIZE $FILENAME" && echo -e "Saved to \e[0;94m$FILENAME-$SIZE.png\e[0m" fi exit 0