#!/usr/bin/env sh

echo " 

 ____ ____ ____ ____ ____ _________ ____ ____ ____ 
||c |||a |||d |||e |||t |||       |||k |||i |||t ||
||__|||__|||__|||__|||__|||_______|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/_______\|/__\|/__\|/__\|

				 UTILITY INSTALLER	
"
echo "cadet-kit needs authorization to install export plugin utilities"
echo "Enter password to authorize install:"

sudo echo "
"

DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd "${DIR}"

SKETCH_EXISTS=$(ls ~/Library/Application\ Support | grep "com.bohemiancoding.sketch3")
if test "$SKETCH_EXISTS" 
then
echo "Installing Sketch export plugin..." 
sudo mkdir -p $DIR/cadetkit-sketch-exporter/cadetkit-sketch-exporter.sketchplugin ~/Library/Application\ Support/com.bohemiancoding.sketch3/Plugins/cadetkit-sketch-exporter
sudo cp -fa $DIR/cadetkit-sketch-exporter/cadetkit-sketch-exporter.sketchplugin ~/Library/Application\ Support/com.bohemiancoding.sketch3/Plugins/cadetkit-sketch-exporter
sudo chmod -R +x $DIR/cadetkit-sketch-exporter/cadetkit-sketch-exporter.sketchplugin ~/Library/Application\ Support/com.bohemiancoding.sketch3/Plugins/cadetkit-sketch-exporter
echo "
"
fi

ILL_PATH=$(ls /Applications | grep "Adobe Illustrator*")
if test "$ILL_PATH"
then
IFS=$'\n' read -rd '' -a APP_PATHS <<<"$ILL_PATH"
## now loop through the above array
for i in "${APP_PATHS[@]}"
do
echo "Installing Adobe Illustrator script to /Applications/$i..."
sudo cp -f $DIR/cadetkit-illustrator-exporter.jsx "/Applications/$i/Presets.localized/en_US/Scripts"
echo "
"
done

fi

#!/bin/bash

# config
IMGS=(
"
 +      o     +              o    \n\
     +             o     +       +\n\
 o          +                     \n\
     o  +           +        +    \n\
 +        o     o       +        o\n\
 -_-_-_-_-_-_-_,------,      o    \n\
 _-_-_-_-_-_-_-|   /\_/\          \n\
 -_-_-_-_-_-_-~|__( ^ .^)  +     +\n\
 _-_-_-_-_-_-_-\"\"  \"\"         \n\
 +      o         o   +       o   \n\
     +         +                  \n\
 o        o         o      o     +\n\
     o           +                \n\
 +      +     o        o      +   \n
" "
     o  +           +        +    \n\
 o          +                    o\n\
     o                 +          \n\
 +      o     +              o    \n\
  o     +        o               +\n\
 _-_-_-_-_-_-_-,------,  o      + \n\
 -_-_-_-_-_-_-_|   /\_/\    +     \n\
 _-_-_-_-_-_-_~|__( ^ .^)     o   \n\
 -_-_-_-_-_-_-_  \"\"  \"\"       \n\
 +      +     o        o      +   \n\
 o        +                o     +\n\
 +      o         +     +       o \n\
     +         +                  \n\
        +           o        +    \n
" )
REFRESH="0.5"
AUDIO_FILE="/tmp/nyan-cat.mp3"
# end

# count lines of first ascii picture in array
LINES_PER_IMG=$(( $(echo $IMGS[0] | sed 's/\\n/\n/g' | wc -l) + 1 ))

# tput $1 LINES_PER_IMG times, used for cuu1(cursor up) cud1(cursor down)
tput_loop() { for((x=0; x < $LINES_PER_IMG; x++)); do tput $1; done; }

# ^C abort, script cleanup
trap sigtrap INT
sigtrap()
    {
    # make cursor visible again
    tput cvvis

    # reset cursor
    tput_loop "cud1"

    # stop audio
    #kill `pgrep vlc`
    #kill `pgrep mplayer` 2&> /dev/null

    echo "caught signal SIGINT(CTRL+C), quitting ..."
    exit 1
    }

# need multi-space strings
IFS='%'

# start audio, vlc & mplayer examples
#vlc $AUDIO_FILE --quiet --loop --volume=100 &
#mplayer -really-quiet -loop 0 $AUDIO_FILE < /dev/null &

# hide the cursor
tput civis

# main loop, pretty self explanatory
while [ 1 ]; do for x in "${IMGS[@]}"; do
    printf $x
    tput_loop "cuu1"
    sleep $REFRESH
done; done

# will never reach here, CTRL+C is required to quit
