LINUX LITE 7.2 FINAL RELEASED - SEE RELEASE ANNOUNCEMENTS SECTION FOR DETAILS


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Info tool
#1
This is a small info tool I've made. It displays some Hardware and System info.

Code:
#! /bin/bash
#--------------------------------------------------------------------------------------------------------
# Info tool by Misko_2083
#--------------------------------------------------------------------------------------------------------

#inxi installed?
if [ -z "$(which inxi)"  ]; then

    if zenity --title="Question" --question text="Inxi is not installed, do you want to install it?\nIf you choose No program will exit."
    then
        gksudo "sudo apt-get install inxi -y" | zenity --progress --title="Installing inxi" --text="please wait" --pulsate --auto-close
                if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                    zenity --error --title="Error" --text="inxi could not be installed."
                    exit
                fi
    else
        exit
    fi
fi

disk_df=(FALSE "Fs disk space info" "df -Th | grep /dev/sd" "View filesystem disk space usage")

FDISK=(FALSE "List Partitions" "sudo fdisk -l" "List out the partition information (password required)")

BLOCKDEV=(FALSE "Display Block Devices" "lsblk" "List out information all block devices")

lspci_info=(FALSE "PCI info" "lspci -vnn" "View PCI devices info")

lspci_graph=(FALSE "Graphics" "lspci -vnn | grep VGA -A 12" "View graphics devices info")

lsusb_info=(FALSE "USB info" "lsusb" "View usb devices info")

CPU=(FALSE "32/64 bit CPU" " " "Find out is this 32 or 64 bit CPU")

CPUZ=(FALSE "Processor info" "lscpu" "Display detailed info on CPU")

OS=(FALSE "32/64 bit OS" "uname -a" "Find out is this 32 or 64 bit OS")

inxi_full=(FALSE "Full info" "inxi -Fxz" "View system info")

inxi_df=(FALSE "Partition info" "inxi -plu" "View partition info")

REPOS=(FALSE "View Repositories" "inxi -r" "View repositories on this sistem")

GRAPHICS=(FALSE "View Graphics" "inxi -Gxx" "View graphics on this sistem")

AUDIO=(FALSE "View Audio" "inxi -A" "View audio on this sistem")

NETWORK=(FALSE "View Network" "inxi -nz" "View network on this sistem")

NETWORKC=(FALSE "Network Configuration" "ifconfig -a" "View network  configuration on this sistem")

OPENGL=(FALSE "View OpenGL configuration" "glxinfo | grep OpenGL" "View OpenGL configuration on this sistem")

LSB=(FALSE "View lsb release" "lsb_release -dic" "View lsb release info")

ic="/usr/share/icons/zenity-llcc.png"
selection=$(zenity --window-icon="$ic" --list --radiolist --width=900 --height=700 --column="Select" --column="Name" --column="Command" \
--column="Description" --text="Select the info tool you wish to use, then click the Display button." --title="Info" --ok-label="Display" --cancel-label="Quit" --separator="\n" \
"${disk_df[@]}" \
"${FDISK[@]}" \
"${BLOCKDEV[@]}" \
"${lspci_info[@]}" \
"${lspci_graph[@]}" \
"${lsusb_info[@]}" \
"${CPU[@]}" \
"${CPUZ[@]}" \
"${OS[@]}" \
"${inxi_full[@]}" \
"${inxi_df[@]}" \
"${REPOS[@]}" \
"${GRAPHICS[@]}" \
"${AUDIO[@]}" \
"${NETWORK[@]}" \
"${NETWORKC[@]}" \
"${OPENGL[@]}" \
"${LSB[@]}" )

# If Quit is clicked then exit
if [ "${PIPESTATUS[0]}" -ne "0" ]; then
exit 0
fi

# check if anything is selected
echo $selection | grep '[a-zA-Z0-9]'
if [ "${PIPESTATUS[1]}" -ne "0" ]; then
zenity --info --title='Info' --text='Nothing was selected.'
exit 0
fi

echo $selection | grep "^Fs disk space info" > /dev/null
if [ $? = 0 ];then
    SOME_TEXT="df - View file system disk space usage\nYou can select the mount to open in the file manager"
    SOME_TITLE="df"

    df -h -T| tail -n+2 | while read fs type size used rest target; do
        if [[ $rest ]] ; then
            echo "$fs" "$type" "$size"B "$used"B "$rest"B "${target[@]}" |  grep /dev/sd | # remove "grep /dev/sd |" to show all
            awk '{print $1,"\n",$2,"\n",$3,"\n",$4,"\n",$5,"\n",$6}BEGIN{ s = 7; e = 35; }{for (i=s; i<=e; i++) printf("%s%s", $(i), i<e ? OFS : "\n"); }' #Workaround for disk labels that contain whitespaces(number of characters that can be divided by whitespace =e-s)
        fi
    done | sed -e 's/[ \t]*$//' $1|zenity --list --width=685 --height=350 --title="${SOME_TITLE}" --text="${SOME_TEXT}" --column="Device" --column="Type" --column="Size" --column="Used" --column="Free" --column="%Used" --column="Mount" --print-column="7"| cut -d '|' -f2| tee /tmp/tempdf

    #With radiolist is also an option
    #done | sed -e 's/[ \t]*$//' $1| sed 's!^/dev/sd*!FALSE\n/dev/sd!g' | zenity --list --radiolist --width=685 --height=350 --title="${SOME_TITLE}" --text="${SOME_TEXT}" --column="Select" --column="FS" --column="Type" --column="Size" --column="Used" --column="Free" --column="%Used" --column="Mount" --print-column="8"| cut -d '|' -f2| tee /tmp/tempdf


    if [ -z "$(cat /tmp/tempdf)" ]; then
    exit 0
    fi

    xdg-open "$(cat /tmp/tempdf)"
    rm -f /tmp/tempdf
fi

echo $selection | grep "List Partitions" > /dev/null
if [ $? = 0 ];then
    gksudo --message 'To run this tool your password is required. Enter your password, or press Cancel.' 'sudo fdisk -l' |tee /tmp/lsblkinfo.txt| zenity --title="PCI info" --text-info --width=800 --height=600 --ok-label="Open in Leafpad" --cancel-label="Close"
    if [ "${PIPESTATUS[2]}" -ne "1" ]; then
         leafpad /tmp/lsblkinfo.txt; rm /tmp/lsblkinfo.txt
    else
        exit 0
    fi
fi

echo $selection | grep "Display Block Devices" > /dev/null
if [ $? = 0 ];then
    lsblk | zenity --title="PCI info" --text-info --width=800 --height=600 --ok-label="Open in Leafpad" --cancel-label="Close"
    if [ "${PIPESTATUS[1]}" -ne "1" ]; then
        lsblk > /tmp/lsblkinfo.txt; leafpad /tmp/lsblkinfo.txt; rm /tmp/lsblkinfo.txt
    else
        exit 0
    fi
fi

echo $selection | grep "PCI info" > /dev/null
if [ $? = 0 ];then
    lspci -vnn | zenity --title="PCI info" --text-info --width=800 --height=600 --ok-label="Open in Leafpad" --cancel-label="Close"
    if [ "${PIPESTATUS[1]}" -ne "1" ]; then
        lspci -nn > /tmp/lspciinfo.txt; leafpad /tmp/lspciinfo.txt; rm /tmp/lspciinfo.txt
    else
        exit 0
    fi
fi

echo $selection | grep "^Graphics$" > /dev/null
if [ $? = 0 ];then
    lspci -vnn | grep VGA -A 12 | zenity --title="Graphics" --text-info --width=800 --height=600 --ok-label="Open in Leafpad" --cancel-label="Close"
    if [ "${PIPESTATUS[2]}" -ne "1" ]; then
        lspci -vnn | grep VGA -A 12  > /tmp/lspcigraph.txt; leafpad /tmp/lspcigraph.txt; rm /tmp/lspcigraph.txt
    else
        exit 0
    fi
fi

echo $selection | grep "USB info" > /dev/null
if [ $? = 0 ];then
    lsusb | zenity --title="USB info" --text-info --width=800 --height=400 --ok-label="Open in Leafpad" --cancel-label="Close"
    if [ "${PIPESTATUS[1]}" -ne "1" ]; then
        lsusb > /tmp/lsusbinfo.txt; leafpad /tmp/lsusbinfo.txt; rm /tmp/lsusbinfo.txt
    else
        exit 0
    fi
fi

echo $selection | grep "32/64 bit CPU" > /dev/null
if [ $? = 0 ];then
    if [ "$(egrep -c ' lm ' /proc/cpuinfo)" -lt "1" ]; then
        bus_zen="32"
    else
        bus_zen="64"
    fi
        zenity --title="32/64 bit CPU" --info --text="This is $bus_zen bit CPU"
fi


echo $selection | grep "Processor info" > /dev/null
if [ $? = 0 ];then
    lscpu | zenity --title="Processor info" --text-info --width=850 --height=600 --ok-label="Open in Leafpad" --cancel-label="Close"
    if [ "${PIPESTATUS[1]}" -ne "1" ]; then
        lscpu > /tmp/processorinfo.txt; leafpad /tmp//tmp/processorinfo.txt; rm /tmp/processorinfo.txt
    else
        exit 0
    fi
fi

echo $selection | grep "32/64 bit OS" > /dev/null
if [ $? = 0 ];then
    if [ "$(uname -a | egrep -c 'i386|i486|i586|i686')" -eq "1" ]; then
        os_zen="32"
    else
        os_zen="64"
    fi
        zenity --title="32/64 bit OS" --info --text="This is $os_zen bit OS"
fi

echo $selection | grep "Full info" > /dev/null
if [ $? = 0 ];then
    inxi -Fxz -c 0 | zenity --title="Full info" --text-info --width=850 --height=600 --ok-label="Open in Leafpad" --cancel-label="Close"
    if [ "${PIPESTATUS[1]}" -ne "1" ]; then
        inxi -Fxz -c 0 > /tmp/inxifull.txt; leafpad /tmp/inxifull.txt; rm /tmp/inxifull.txt
    else
        exit 0
    fi
fi

echo $selection | grep "Partition info" > /dev/null
if [ $? = 0 ];then
    inxi -plu -c 0 | zenity --title="Partition info" --text-info --width=650 --height=400 --ok-label="Open in Leafpad" --cancel-label="Close"
    if [ "${PIPESTATUS[1]}" -ne "1" ]; then
        inxi -plu -c 0 > /tmp/partitionsinfo.txt; leafpad /tmp/partitionsinfo.txt; rm /tmp/partitionsinfo.txt
    else
        exit 0
    fi
fi

echo $selection | grep "View Repositories" > /dev/null
if [ $? = 0 ];then
    inxi -r -c 0| zenity --title="Repositories" --text-info --width=850 --height=600 --ok-label="Open in Leafpad" --cancel-label="Close"
    if [ "${PIPESTATUS[1]}" -ne "1" ]; then
        inxi -r -c 0 > /tmp/repositorieslist.txt; leafpad /tmp/repositorieslist.txt; rm /tmp/repositorieslist.txt
    else
        exit 0
    fi    
fi

echo $selection | grep "View Graphics" > /dev/null
if [ $? = 0 ];then
    inxi -Gxx -c 0| zenity --title="Graphics info" --text-info --width=850 --height=600 --ok-label="Open in Leafpad" --cancel-label="Close"
    if [ "${PIPESTATUS[1]}" -ne "1" ]; then
        inxi -Gxx -c 0 > /tmp/graphicsinfo.txt; leafpad /tmp/graphicsinfo.txt; rm /tmp/graphicsinfo.txt
    else
        exit 0
    fi
fi

echo $selection | grep "View Audio" > /dev/null
if [ $? = 0 ];then
    inxi -A -c 0| zenity --title="Audio info" --text-info --width=850 --height=600 --ok-label="Open in Leafpad" --cancel-label="Close"
    if [ "${PIPESTATUS[1]}" -ne "1" ]; then
        inxi -A -c 0 > /tmp/audioinfo.txt; leafpad /tmp/audioinfo.txt; rm /tmp/audioinfo.txt
    else
        exit 0
    fi
fi

echo $selection | grep "^View Network$" > /dev/null
if [ $? = 0 ];then
    inxi -nz -c 0 | zenity --title="Network info" --text-info --width=850 --height=600 --ok-label="Open in Leafpad" --cancel-label="Close"
    if [ "${PIPESTATUS[1]}" -ne "1" ]; then
        inxi -nz -c 0 > /tmp/networkinfo.txt; leafpad /tmp/networkinfo.txt; rm /tmp/networkinfo.txt
    else
        exit 0
    fi
fi

echo $selection | grep "Network Configuration" > /dev/null
if [ $? = 0 ];then
    ifconfig -a | zenity --title="Network info" --text-info --width=850 --height=600 --ok-label="Open in Leafpad" --cancel-label="Close"
    if [ "${PIPESTATUS[1]}" -ne "1" ]; then
        ifconfig -a > /tmp/networkconfinfo.txt; leafpad /tmp/networkconfinfo.txt; rm /tmp/networkconfinfo.txt
    else
        exit 0
    fi
fi

echo $selection | grep "View OpenGL configuration" > /dev/null
if [ $? = 0 ];then
    glxinfo | grep OpenGL| zenity --title="View OpenGL configuration" --text-info --width=850 --height=600 --ok-label="Open in Leafpad" --cancel-label="Close"
    if [ "${PIPESTATUS[2]}" -ne "1" ]; then
        glxinfo | grep OpenGL > /tmp/openglinfo.txt; leafpad /tmp/openglinfo.txt; rm /tmp/openglinfo.txt
    else
        exit 0
    fi
fi

echo $selection | grep "View lsb release" > /dev/null
if [ $? = 0 ];then
    lsb_release -dic| zenity --title="lsb_release" --text-info --width=850 --height=600 --ok-label="Open in Leafpad" --cancel-label="Close"
    if [ "${PIPESTATUS[1]}" -ne "1" ]; then
        lsb_release -dic > /tmp/lsbinfo.txt; leafpad /tmp/lsbinfo.txt; rm /tmp/lsbinfo.txt
    else
        exit 0
    fi
fi
Reply


Messages In This Thread
Info tool - by misko_2083 - 11-14-2014, 02:17 AM
Re: Info tool - by rokytnji - 11-14-2014, 04:49 PM
Re: Info tool - by rokytnji - 11-14-2014, 07:09 PM
Re: Info tool - by misko_2083 - 11-14-2014, 08:06 PM
Re: Info tool - by rokytnji - 11-14-2014, 08:36 PM
Re: Info tool - by rokytnji - 11-14-2014, 08:53 PM
Re: Info tool - by rokytnji - 11-14-2014, 09:01 PM
Re: Info tool - by gold_finger - 11-14-2014, 11:56 PM
Re: Info tool - by rbdflyboy - 11-15-2014, 12:09 AM
Re: Info tool - by shengchieh - 11-15-2014, 03:17 AM
Re: Info tool - by misko_2083 - 11-15-2014, 10:30 PM
Re: Info tool - by mlsmith - 11-28-2014, 02:23 PM
Re: Info tool - by TMG1961 - 11-28-2014, 04:55 PM
Re: Info tool - by rokytnji - 11-28-2014, 05:34 PM
Re: Info tool - by TMG1961 - 11-28-2014, 09:52 PM
Re: Info tool - by sysdrum - 11-28-2014, 10:09 PM
Re: Info tool - by mlsmith - 11-29-2014, 04:00 AM
Re: Info tool - by sysdrum - 11-29-2014, 04:59 AM
Re: Info tool - by misko_2083 - 11-29-2014, 07:57 AM
Re: Info tool - by sysdrum - 11-29-2014, 08:50 AM

Forum Jump:


Users browsing this thread: 8 Guest(s)