#!/bin/bash
if [[ ! -d $HOME'/.gens' ]];then
    mkdir $HOME'/.gens/'
    cp /opt/astra-genesis-pack/emulator/gens.cfg $HOME'/.gens/'
    mkdir $HOME'/.gens/plugins/'
    cp /opt/astra-genesis-pack/emulator/lib/mdp/* $HOME'/.gens/plugins/'
    X=$(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f1)
    Y=$(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f2)
    line=53
    sed -e "${line}cOpenGL Height=$Y" -i -- $HOME'/.gens/gens.cfg'
    line=54
    sed -e "${line}cOpenGL Width=$X" -i -- $HOME'/.gens/gens.cfg'
    line=15
    sed -e "${line}cSave Path=$HOME/.gens/" -i -- $HOME'/.gens/gens.cfg'
    echo "1" >> /opt/astra-genesis-pack/launcher/config
    /opt/astra-genesis-pack/launcher/launcher
else
    /opt/astra-genesis-pack/launcher/launcher
fi
exit 0
