#!/bin/bash
# File Name: inxi-gui
# Version: 1.0.1
# Purpose: easy to use gui for the inxi script
# Authors: Dave and minor modifications by anticapitalista
# Matching inxi version: 1.8.10
# Acknowledgements: Scott Rogers, Harald Hope, aka trash80 & h2 for inxi version. Antix forum users for suggestions, testing, and input
# Special Acknowledgements: anticapitalista for testing, suggestions, input

# Copyright (C) Sunday, Feb. 5, 2011  by Dave / david.dejong02@gmail.com
# Minor changes June 26, 2012 by anticapitalista / antiX@operamail.com
# License: gplv2
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#################################################################################################################################################

TEXTDOMAINDIR=/usr/share/locale
TEXTDOMAIN=inxi-gui

# Help function - displays possible variables that can be used
function help {
	echo $"    -a|--audio		view sound card information"
	echo $"    -c|--cpu    	        view cpu information"
	echo $"    -g|--graphics	view graphics card information"
	echo $"    -n|--nic		view nic information" 
	echo $"    -l|--system		view system information" 
	echo $"    -hd|--hard-drive	view hard drive information" 
	echo $"    -r|--repository	view repository" 
	echo $"    -s|--sensor		view sensor information" 
	echo $"    --all		view all (short) information" 
        echo $"    --std		view standard information"
	echo $"    --help		display this help"
	echo
	exit
}

# Main Function ( starts if functions below are not called by user )
function start {
	   	A=$"Audio"
		B=$"CPU"
		C=$"Graphics"
		D=$"NIC and IP address"
		E=$"System"
		F=$"Hard Drive"
		G=$"Repository"
		H=$"Sensor Output"
		I=$"All Short"
                J=$"Standard"
		ans=$(yad  --width 280 --height 400 --list  --title $"PC Information Options" \
            --column "PC INFO" \
            --separator="" \
            "$A"\
            "$B"\
            "$C"\
            "$D"\
            "$E"\
            "$F"\
            "$G"\
            "$H"\
            "$I"\
            "$J")
		echo $ans
		CASEITEM=`echo $ans |cut -d "|" -f2`
		case $CASEITEM in
		$A)
		roxterm -T 'PC Information' -e bash -c 'inxi-gui -a ; bash' 
		inxi-gui
                ;;
		$B)
		roxterm -T 'PC Information' -e bash -c 'inxi-gui -c ; bash' 
		inxi-gui
                ;;
		$C)
		roxterm  -T 'PC Information' -e bash -c 'inxi-gui -g ; bash' 
		inxi-gui
                ;;
		$D)
		roxterm -T 'PC Information' -e su -c 'inxi-gui -n ; bash' 
		inxi-gui
		;;
		$E)
		roxterm -T 'PC Information' -e bash -c 'inxi-gui -l ; bash' 
		inxi-gui
		;;
		$F)
		roxterm -T 'PC Information' -e bash -c 'inxi-gui -hd ; bash'
		inxi-gui
		;;
		$G)
		roxterm -T 'PC Information' -e bash -c 'inxi-gui -r ; bash' 
		inxi-gui
		;;
		$H)
		roxterm -T 'PC Information' -e bash -c 'inxi-gui -s ; bash' 
		inxi-gui
		;;
		$I)
		roxterm -T 'PC Information' -e bash -c 'inxi-gui -all ; bash' 
		inxi-gui		i
		;;
                $J)
		roxterm -T 'PC Information' -e bash -c 'inxi-gui -std ; bash' 
		inxi-gui		i
		;;
		*)
		esac    
		}

# Function for sound card information
function a {
		echo ""
		echo "################### PC INFORMATION - audio #####################"
		echo "################### Press CTRL + C to exit #####################"
		echo "" 
		inxi -A 
		sleep 10000
		inxi-gui
		}

# Function for cpu
function b {
		echo ""
		echo "################### PC INFORMATION  -  cpu #####################"
		echo "################### Press CTRL + C to exit #####################" 
		echo ""
		inxi -C 
		sleep 10000
		}

# Function for graphics
function c {
		echo ""
		echo "################### PC INFORMATION - graphics #####################"
		echo "#################### Press CTRL  + C to exit ######################" 
		echo ""
		inxi -G
		sleep 10000
		}

# Function for nic and ip
function d {
		echo ""
		echo "################### PC INFORMATION - nic + IP #####################"
		echo "##################### Press CTRL + C to exit ######################" 
		echo ""
		inxi -i
		echo ""
		ifconfig
		sleep 10000
		}

# Function for system
function e {
		echo ""
		echo "################### PC INFORMATION - system #####################"
		echo "################### Press CTRL  + C to exit #####################" 
		echo ""
		inxi -S
		echo ""
		inxi -t c10
		echo ""
		inxi -I
		sleep 10000
		}

# Function for hard drive
function f {
		echo ""
		echo "################### PC INFORMATION - hard drive #####################"
		echo "##################### Press CTRL  + C to exit #######################" 
		echo ""
		inxi -D
		inxi -p
		sleep 10000
		}

# Function for repositories
function g {
		echo ""
		echo "################### PC INFORMATION - repositories #####################"
		echo "###################### Press CTRL  + C to exit ########################" 
		echo ""
		inxi -r 
		sleep 1 && yad --image "question" --title $"Edit?" --text $"Edit Repositories?"
		if [ $? = 0 ] ; then
		gksu geany /etc/apt/sources.list.d/*.list &
                sleep 55
		else 
		inxi-gui &
		fi
                killall roxterm
		sleep 10000
		}

# Function for sensors
function h {
		echo ""
		echo "################### PC INFORMATION - sonsors #####################"
		echo "#################### Press CTRL + C to exit ######################" 
		echo ""
		inxi -s
		sleep 10000
		}

# Function for all short
function i {
		echo ""
		echo "#################### PC INFORMATION - all ######################"
		echo "################### Press CTRL + C to exit #####################" 
		echo ""
		inxi -F
		sleep 10000
		}

# Function for standard
function j {
		echo ""
		echo "#################### PC INFORMATION - all ######################"
		echo "################### Press CTRL + C to exit #####################" 
		echo ""
		inxi -Sxxxr
		sleep 10000
		}       

# Setting possible variable options
AA=false
BB=false
CC=false
DD=false
EE=false
FF=false
GG=false
HH=false
II=false
JJ=false
HELP=false

for args; do
case "$1" in
		-a|--audio) AA=true;;
		-c|--cpu) 	BB=true;;
		-g|--graphics) 	CC=true;;
		-n|--nic) DD=true;;
		-l|--system) EE=true;; 
		-hd|--hard-drive) FF=true;;
		-r|--repository) GG=true;;
		-s|--sensor) HH=true;;
		-all|--all) II=true;;
                -std|--std) JJ=true;;
		-h|--help) 	HELP=true;;
		--) 		shift; break;;
		-*) 		echo $"Unrecognized option: $1"; ERROR=true;;
		*) 		break;;
	esac
shift
done

$AA && {
	a
	exit
}

$BB && {
	b
	exit
}

$CC && {
	c
	exit
}

$DD && {
	d
	exit
}

$EE && {
	e
	exit
}

$FF && {
	f
	exit
}

$GG && {
	g
	exit
}

$HH && {
	h
	exit
}

$II && {
	i
	exit
}

$JJ && {
	j
	exit
}

$HELP && {
	help
	exit
}


# Execute if script function is NOT called
start 
