All pastes #1945124 Raw Edit

whatGPU.sh

public shellscript v1 · immutable
#1945124 ·published 2010-09-20 15:28 UTC
rendered paste body
#! /bin/shif ! lshw -version &> /dev/null; then	echo "Please, install lshw utility"	exit 0firamregions(){	ram=`awk '{for (i=1;i<=NF;i++) if ($i ~ "memory") print $i}' | awk -F : '{print $2}' | tr a-z A-Z`	echo -e "ibase=16;\n$ram" | bc | awk '{sum+=$1}END{print (0-sum)/1024/1024"MB"}'}cpu2gpu(){	if echo "$@" | grep -q "Core Processor"; then		echo `grep "model name" /proc/cpuinfo | head -1 | awk -F : '{print $2}' | sed 's/[ ]\{2,\}/ /g;s/^ *//;s/ *$//'`" Integrated Graphics"	else		echo "$@"	fi}outfile=`mktemp` || exit 1lshw -class display -disable dmi -quiet &> "$outfile" || exit 2cat "$outfile" | while read a; do	case "$a" in		*product:*)			gpu=`echo $a | awk -F 'product: ' '/product:/ {print $2}'`		;;		*memory:*)			ram=`echo $a | ramregions`		;;	esac	if [ -n "$gpu" -a -n "$ram" ]; then		gpu=`cpu2gpu "$gpu"`		echo "GPU: [$gpu] RAM: [$ram]"		unset gpu		unset ram	fidone/bin/rm $outfile