#!/bin/bash
##########################################################
# Inxi-gui, displays information about your pc hardware  #
#                                                        #
# Gui Author Ken Dotson <lxgator@gmail.com>              #
#                                                        #
##########################################################
# Drives
SAVE='Save!/usr/share/inxi-gui/data/icons/save.svg'
OK='Ok!/usr/share/inxi-gui/data/icons/ok.svg'
CANCEL='Cancel!/usr/share/inxi-gui/data/icons/cancel.svg'

PID=`ps -eaf | grep "inxi-gui" | grep -v grep | awk '{print $2}'`
if [[ "" !=  "$PID" ]]; then
ICON='/usr/share/icons/hicolor/48x48/apps/inxi-gui.svg'
inxi -d -c 0 | tr -d '<>,' | tr -d '(),'|sed 's/^[ \t]*//' > /tmp/inxi
FILE='/tmp/inxi'
AF=`cat "$FILE" |awk '{print $0}'`
kill -9 $PID > /dev/null 2>&1 | yad --width=550 --height=125 --fixed --image=$ICON --center --title=Drives \
--text="\\n$AF" --window-icon=$ICON --button=$SAVE:1 --button=$OK:0
if [ $? = 1 ]; then
ENTRY=$(yad --width=400 --window-icon=$ICON --center \
        --form --title="Inxi GUI" \
        --field="Save in:DIR" "$HOME/Desktop" \
--text='\nSave Drives Information' \
--button=$CANCEL:1 --button=$OK:0)
if [ $? = "1" ]; then
pkill -SIGKILL "A7" 2>&1 |less &
inxi-gui
fi
    RET=$?

    OIFS=$IFS
    IFS="|"
    i=0
    retChoice=()

    for ret in $ENTRY;do
        retChoice[$i]="$ret"
        i=$(($i+1))
    done

    IFS=$OIFS
    SAVEDIR=${retChoice[0]} # directory path
if [ $? = 0 ]; then
FILE='/tmp/inxi'
AF=`cat "$FILE" |awk '{print $0}'`
echo "$AF" | awk '{ print $0 }' | column -x > "$SAVEDIR/Drives"
fi
 fi
exec "inxi-gui"
fi &
