Linux System Stats Script


Recommended Posts

You could make life easier for yourself and do something like this:

de="$(echo ${DESKTOP_SESSION} | sed 's/^./\U&/')"

That would assign the variable "de" with the desktop session value, with the first letter capitalized. ("Gnome", "Kde", "Xfce", etc).

If you wanted to be more advanced you could do something like this to save you having to update the script every time someone came out with a new DE (as long as the script handled the capitalization correctly):

GetDesktopEnvironmentVersion()
{
    case "${DESKTOP_SESSION}" in

        gnome)
            echo "$(gnome-session --version | awk {'print $2'})"
            return 0
            ;;

        kde)
            echo "$(kde-open -v | awk '/Platform/ {print $4}')"
            return 0
            ;;

    esac

    # Return 1 if the DE does not match a known DE we can get the version for.
    # This allows us to check the return code if we like.
    return 1
}

# Assume that any DE with a name shorter than 5 chars is an abbreviation. GNOME is an exception, since it should be capitalized still.
if [ ${#DESKTOP_SESSION} -le 4 ] || ${DESKTOP_SESSION} | grep -i "gnome" &> /dev/null; then
    de="$(echo ${DESKTOP_SESSION} | tr [:lower:] [:upper:])"
else
    de="$(echo ${DESKTOP_SESSION} | sed 's/^./\U&/')"
fi
de="${de} $(GetDesktopEnvironmentVersion)"

`echo $de` would result in the following:

  • "Cinnamon"
  • "GNOME 3.6.2"
  • "KDE 4.0.0"
  • "XFCE"
  • "Openbox
  • "Unity"
  • "MATE"

yeah some openbox sessions set the $DESKTOP_SESSION some dont

new version hopefully will pick up unity and cinnamon

http://www.haggistech.co.uk/stats-V0.8.1.tar.gz

work to go to now :(

GetDesktopEnvironmentVersion()
{
	case "${DESKTOP_SESSION}" in

		gnome)
			echo "$(gnome-session --version | awk {'print $2'})"
			return 0
			;;

		kde)
			echo "$(kde-open -v | awk '/Platform/ {print $4}')"
			return 0
			;;

	esac

	# Return 1 if the DE does not match a known DE we can get the version for.
	# This allows us to check the return code if we like.
	return 1
}

# Assume that any DE with a name shorter than 5 chars is an abbreviation. GNOME is an exception, since it should be capitalized still.
if [ ${#DESKTOP_SESSION} -le 4 ] || ${DESKTOP_SESSION} | grep -i "gnome" &> /dev/null; then
	de="$(echo ${DESKTOP_SESSION} | tr [:lower:] [:upper:])"
else
	de="$(echo ${DESKTOP_SESSION} | sed 's/^./\U&/')"
fi
de="${de} $(GetDesktopEnvironmentVersion)"

`echo $de` would result in the following:

  • "Cinnamon"
  • "GNOME 3.6.2"
  • "KDE 4.0.0"
  • "XFCE"
  • "Openbox
  • "Unity"
  • "MATE"

running your code i get this

not sure why though


OS: Fedora 17 (Beefy Miracle)
Hostname: haggislaptop
Uptime: 21:18 hours
[b]./stats.sh: line 107: gnome: command not found[/b]
CPU: Intel(R) Pentium(R) Dual CPU T3400 @ 2.16GHz
Total RAM: 1949 Mb
Desktop Enviroment:
Logged in as: haggis
Kernel: 3.6.8-2.fc17.i686
Resolution: 1440x900 pixels
Load Averages: 0.63, 0.62, 0.68
[/CODE]

I think I have discovered why checking $DESKTOP_SESSION works for some people but not others. It has nothing to do with Debian, Ubuntu, Fedora, Openbox, Mate, etc. It is reliant on your display manager. I am using Slim on my laptop, which doesn't set $DESKTOP_SESSION. I noticed that switching to LightDM or GDM and logging into Openbox actually sets the $DESKTOP_SESSION to openbox.

Summary: Detecting desktop environment based on $DESKTOP_SESSION is unreliable at best.

running your code i get this

not sure why though

	OS: Fedora 17 (Beefy Miracle)
	Hostname: haggislaptop
	Uptime: 21:18 hours
[b]./stats.sh: line 107: gnome: command not found[/b]
	CPU: Intel(R) Pentium(R) Dual CPU T3400 @ 2.16GHz
	Total RAM: 1949 Mb
	Desktop Enviroment:
	Logged in as: haggis
	Kernel: 3.6.8-2.fc17.i686
	Resolution: 1440x900 pixels
	Load Averages: 0.63, 0.62, 0.68
[/CODE]


Because I borked up my code >.<.
I missed an echo command, the if statement should have read: 
[code]
if [ ${#DESKTOP_SESSION} -le 4 ] || echo ${DESKTOP_SESSION} | grep -i "gnome" &> /dev/null; then

Doesn't really matter if DESKTOP_SESSION is unreliable though :(

I refactored stats 0.8.1 and developed a method to make desktop environment detection much more reliable. The new version is attached to this post, and the patch I created against 0.8.1 is below.


--- stats.sh.orig 2012-12-04 16:18:57.000000000 -0500
+++ stats.sh 2012-12-05 19:06:46.241149549 -0500
@@ -1,119 +1,322 @@
#!/bin/bash
-clear
-
-
-echo ""
-#echo " ___"
-#echo " ,g@@@@@@@@@@@p, "
-#echo " ,@@@@@@@@@@@D****4@@. "
-#echo " ,@@@@@@@@@@P' '%@. "
-#echo " y@@@@@@@@@@F ,g@@p. !3@k "
-#echo " !@@@@@@@@@@@. !@@@@@@@@@@@@k "
-#echo " :@@@@@@@@@@@@ J@@@@@@@@@@@@@L "
-#echo " J@@@@@@@@@*** '***@@@@@@@@@@) "
-#echo " J@@@@@@@@@ @@@@@@@@@@) "
-#echo " J@@@@@@@@@@@@ J@@@@@@@@@@@@@L "
-#echo " J@@@@@@@@@@@@ J@@@@@@@@@@@@F "
-#echo " J@@@@@@@@@@@F {@@@@@@@@@@@F "
-#echo " J@@@E. ''*^' i@@@@@@@@@@B^ "
-#echo " J@@@@@._ ,@@@@@@@@@@P' "
-#echo " J@@@@@@@@@@@@@@@@@@BP*' "
-#echo ""
-echo ""
-
-
-
-
-os=$(cat /etc/*-release | grep "^PRETTY_NAME=" | sed -r 's/PRETTY_NAME="?([^"]+)"?/\1/')
-host=$(uname -n)
-kernel=$(uname -r)
-# get the uptime data
-days=$(uptime | awk '{print $3}' | sed 's/,//g')
-hours=$(uptime | awk '{print $5}' | sed 's/,//g')
-label=$(uptime | awk '{print $4}')
-totalram=$(awk '/MemTotal/{print $2}' /proc/meminfo)
-ram=$((totalram/1024))
-user=$(whoami)
-res=$(xdpyinfo | grep dimensions | awk {'print $2'})
-load=$(uptime | awk -F 'load average:' '{ print $2 }')
-cpu=$(cat /proc/cpuinfo | grep "model name" | sed -r 's/model name"?([^"]+)"?:/\1/' | head -n 1)
-
-
-if [ -z "$os" ]
-then
-echo " $(tput bold)$(tput setaf 4)OS:$(tput sgr0) Not Found"
-else
-echo " $(tput bold)$(tput setaf 4)OS:$(tput sgr0)" $os
-fi
-
-echo " $(tput bold)$(tput setaf 4)Hostname:$(tput sgr0)" $host
-
-
-# get the uptime data
-
-days=$(uptime | awk '{print $3}' | sed 's/,//g')
-hours=$(uptime | awk '{print $5}' | sed 's/,//g')
-label=$(uptime | awk '{print $4}')

+# Copyright (c) 2012, Haggis
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met :
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+# * Neither the name of any individual or organization nor the names of its
+# contributors may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# ( INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+########################################################################
+# Global Variables #
+########################################################################
+
+unset os # Human-readable (pretty) name of the operating system
+unset host # Hostname
+unset kernel # Linux kernel build string
+
+unset days # Days the system has been online
+unset hours # Hours the system has been online (in relation to days)
+unset label # Precision of days, hours, minutes, or seconds
+unset day_label # day/days
+unset hour_label # hour/hours
+
+unset totalram # Size of installed RAM in kilabytes
+unset ram # Size of installed RAM in megabytes
+unset user # Name of the user running this script
+unset res # Resolution of the current X session
+unset load # Load average since the last reboot
+unset cpu # CPU identifier information
+
+unset de # Desktop environment (or window manager) running
+unset ver # DE version information, if available
+
+########################################################################
+# Primary Functions #
+########################################################################
+
+# Print a pretty logo for the Linux distribution the user is running.
+function print_logo
+{
+ id="$(cat /etc/*-release | grep -E '^ID[ ]*=[ ]*[A-Za-z]+[ ]*' | cut -d '=' -f 2)"
+ case $id in
+ ubuntu)
+ echo " "
+ echo " ..''''''.. "
+ echo " .;::::::::::::::;. "
+ echo " .;::::::::::::::'.':::;. "
+ echo " .;::::::::;,'..';. .::::;. "
+ echo " .:::::::,.,. ....:::::::. "
+ echo " .:::::::. :;::::,. .:::::::. "
+ echo " ;:::::: .::::::::::. ::::::; "
+ echo " :::. .' ::::::::::::...,:::::: "
+ echo " :::. .' ::::::::::::...,:::::: "
+ echo " ;:::::: .::::::::::. ::::::; "
+ echo " .:::::::. :,;::;,. .:::::::. "
+ echo " .:::::::;.;. ....:::::::. "
+ echo " ;::::::::;,'..';. .::::; "
+ echo " .;::::::::::::::'.':::;. "
+ echo " .,::::::::::::::,. "
+ echo " ...''''... "
+ echo " "
+ ;;
+ mint)
+ echo " "
+ echo ".:::::::::::::::::::::::::;,. "
+ echo ",0000000000000000000000000000Oxl, "
+ echo ",00, ..,cx0Oo. "
+ echo ",00, ,,. .cO0o "
+ echo ",00l,,. '00; .. .. .k0x "
+ echo "'kkkkO0l '00; ck000Odlk000Oo. .00c"
+ echo " d0k '00; x0O:.'d00O;.,k00. x0x"
+ echo " d0k '00; .00x ,00o ;00c d0k"
+ echo " d0k '00; .00d ,00o ,00c d0k"
+ echo " d0k '00; .00d ,00o ,00c d0k"
+ echo " d0k '00; ;;' .;;. .cc' d0k"
+ echo " d0O .00d ... d0k"
+ echo " ;00, :00x:,,,, ..... d0k"
+ echo " o0O, .:dO000k........... d0k"
+ echo " :O0x, x0k"
+ echo " :k0Odc,'.................;x00k"
+ echo " .;lxO0000000000000000000000k"
+ echo " ......................"
+ echo " "
+ ;;
+ fedora)
+ echo " "
+ echo " ___ "
+ echo " ,g@@@@@@@@@@@p, "
+ echo " ,@@@@@@@@@@@D****4@@. "
+ echo " ,@@@@@@@@@@P' '%@. "
+ echo " y@@@@@@@@@@F ,g@@p. !3@k "
+ echo " !@@@@@@@@@@@. !@@@@@@@@@@@@k "
+ echo " :@@@@@@@@@@@@ J@@@@@@@@@@@@@L "
+ echo " J@@@@@@@@@*** '***@@@@@@@@@@) "
+ echo " J@@@@@@@@@ @@@@@@@@@@) "
+ echo " J@@@@@@@@@@@@ J@@@@@@@@@@@@@L "
+ echo " J@@@@@@@@@@@@ J@@@@@@@@@@@@F "
+ echo " J@@@@@@@@@@@F {@@@@@@@@@@@F "
+ echo " J@@@E. ''*^' i@@@@@@@@@@B^ "
+ echo " J@@@@@._ ,@@@@@@@@@@P' "
+ echo " J@@@@@@@@@@@@@@@@@@BP*' "
+ echo " "
+ ;;
+ debian)
+ echo " "
+ echo " _,met$$$$$gg. "
+ echo " ,g$$$$$$$$$$$$$$$P. "
+ echo " ,g$$P$$ $$$Y$$.$. "
+ echo " ,$$P' `$$$. "
+ echo " ',$$P ,ggs. `$$b: "
+ echo " `d$$' ,$P$' . $$$ "
+ echo " $$P d$' , $$P "
+ echo " $$: $$. - ,d$$' "
+ echo " $$; Y$b._ _,d$P' "
+ echo " Y$$. `.`$Y$$$$P$' "
+ echo " `$$b $-.__ "
+ echo " `Y$$b "
+ echo " `Y$$. "
+ echo " `$$b. "
+ echo " `Y$$b. "
+ echo " `$Y$b._ "
+ echo " `$$$$ "
+ echo " "
+ ;;
+ *)
+ echo " "
+ echo " .88888888:. "
+ echo " 88888888.88888. "
+ echo " .8888888888888888. "
+ echo " 888888888888888888 "
+ echo " 88' _`88'_ `88888 "
+ echo " 88 88 88 88 88888 "
+ echo " 88_88_::_88_:88888 "
+ echo " 88:::,::,:::::8888 "
+ echo " 88`:::::::::'`8888 "
+ echo " .88 `::::' 8:88. "
+ echo " 8888 `8:888. "
+ echo " .8888' `888888. "
+ echo " .8888:.. .::. ...:'8888888:. "
+ echo " .8888.' :' `'::`88:88888 "
+ echo " .8888 ' `.888:8888. "
+ echo " 888:8 . 888:88888 "
+ echo " .888:88 .: 888:88888: "
+ echo " 8888888. :: 88:888888 "
+ echo " `.::.888. :: .88888888 "
+ echo " .::::::.888. :: :::`8888'.:. "
+ echo " ::::::::::.888 ' .:::::::::::: "
+ echo " ::::::::::::.8 ' .:8::::::::::::. "
+ echo " .::::::::::::::. .:888::::::::::::: "
+ echo " :::::::::::::::88:.__..:88888:::::::::::' "
+ echo " `'.:::::::::::88888888888.88:::::::::' "
+ echo " `':::_:' -- '' -'-' `':_::::'` "
+ echo " "
+ ;;
+ esac
+}
+
+# Take a screenshot and save it in the user's home directory.
+function print_screenshot
+{
+ echo " Screenshot being taken.....$(tput bold)$(tput setaf 4)Smile!!$(tput sgr0)"
+ echo
+ import -window root "$HOME/Screenshot_$(/bin/date +%Y%m%d.%H%M).png"
+ echo " Screenshot Saved as $HOME/Screenshot_$(/bin/date +%Y%m%d.%H%M).png"
+}
+
+# Collect release information.
+function get_release
+{
+ os=$(cat /etc/*-release | grep "^PRETTY_NAME=" | sed -r 's/PRETTY_NAME="?([^"]+)"?/\1/')
+ [ -z "$os" ] && os='Not Found'
+ host=$(uname -n)
+ kernel=$(uname -r)
+}
+
+# Save the uptime at the time this function is executed.
+function get_uptime
+{
+ # Since uptime changes constantly, save it before parsing so the output is consistent.
+ current_uptime="$(uptime)"
+ # Parse the uptime snapshot.
+ days=$(echo $current_uptime | awk '{print $3}' | sed 's/,//g')
+ if [ "$days" = 1 ]; then
+ day_label='day'
+ else
+ day_label='days'
+ fi
+ hours=$(echo $current_uptime | awk '{print $5}' | sed 's/,//g')
+ if [ "$hours" = 1 ]; then
+ hour_label='hour'
+ else
+ hour_label='hours'
+ fi
+ label=$(echo $current_uptime | awk '{print $4}')
+}
+
+# Collect generic system statistics.
+function get_system_stats
+{
+ totalram=$(awk '/MemTotal/{print $2}' /proc/meminfo)
+ ram=$((totalram/1024))
+ user=$(whoami)
+ res=$(xdpyinfo | grep dimensions | awk {'print $2'})
+ load=$(uptime | awk -F 'load average:' '{ print $2 }')
+ cpu=$(cat /proc/cpuinfo | grep 'model name' | head -n 1 | cut -d ':' -f 2-)
+}
+
+# Determine which desktop environment the user is running.
+function get_desktop_environment
+{
+ # $DESKTOP_SESSION in an UNRELIABLE method for determining which
+ # desktop environment is running. It is tied to the display manager,
+ # not the desktop environment itself. It is useful, though, when it
+ # is set.
+ if [ -z "$DESKTOP_SESSION" ]; then
+ if [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}kdeinit')" ]; then
+ DESKTOP_SESSION='kde-plasma'
+ elif [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}cinnamon')" ]; then
+ DESKTOP_SESSION='cinnamon'
+ elif [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}unity')" ]; then
+ DESKTOP_SESSION='unity'
+ elif [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}gnome-session')" ]; then
+ DESKTOP_SESSION='gnome'
+ elif [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}lxsession')" ]; then
+ DESKTOP_SESSION='LXDE'
+ elif [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}xfce.*-session')" ]; then
+ DESKTOP_SESSION='xfce'
+ elif [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}mate-session')" ]; then
+ DESKTOP_SESSION='mate'
+ elif [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}openbox')" ]; then
+ DESKTOP_SESSION='openbox'
+ elif [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}fluxbox')" ]; then
+ DESKTOP_SESSION='fluxbox'
+ fi
+ fi
+
+ if [ -n "$KDE_FULL_SESSION" ]; then
+ de='KDE'
+ ver=$(kde-open -v | awk '/Platform/ {print $4}')
+ elif [ "$DESKTOP_SESSION" == 'cinnamon' ]; then
+ de='Cinnamon'
+ ver=$(cinnamon --version | cut -d ' ' -f 2)
+ elif [ "$DESKTOP_SESSION" == 'ubuntu' ]; then
+ de='Unity'
+ ver=$(unity --version | cut -d ' ' -f 2)
+ elif [ -n "$GNOME_DESKTOP_SESSION_ID" ]; then
+ de='GNOME'
+ ver=$(gnome-session --version | awk {'print $2'})
+ elif [ "$DESKTOP_SESSION" == 'LXDE' ]; then
+ de='LXDE'
+ ver=$(lxpanel --version | cut -d ' ' -f 2)
+ elif [ "$DESKTOP_SESSION" == 'xfce' ]; then
+ de='XFCE'
+ ver=$(xfce4-session --version | head -n 1 | cut -d ' ' -f 2)
+ elif [ "$DESKTOP_SESSION" == 'mate' ]; then
+ de='Mate'
+ ver=$(mate-session --version | cut -d ' ' -f 2)
+ elif [ "$DESKTOP_SESSION" == 'openbox' ]; then
+ de='Openbox'
+ ver=$(openbox --version | head -n 1 | cut -d ' ' -f 2)
+ elif [ "$DESKTOP_SESSION" == 'fluxbox' ]; then
+ de='Fluxbox'
+ ver=$(fluxbox -version | head -n 1 | cut -d ' ' -f 2)
+ else
+ de='Not Found'
+ fi
+}
+
+########################################################################
+# Main #
+########################################################################

+clear

-
-
-if [ "$days" = 1 ]; then
-day_label='day'
-else
-day_label='days'
-fi
-
-#format labels
-if [ $hours = 1 ]; then
-hour_label='hour'
-else
-hour_label='hours'
-fi
-
-#format output
+get_release
+get_uptime
+get_system_stats
+get_desktop_environment
+
+echo
+print_logo
+echo
+echo " $(tput bold)$(tput setaf 4)OS:$(tput sgr0) $os"
+echo " $(tput bold)$(tput setaf 4)Hostname:$(tput sgr0) $host"
if [ "$label" = 'min,' ]; then
-echo " $(tput bold)$(tput setaf 4)Uptime:$(tput sgr0) "$days "minutes"
+ echo " $(tput bold)$(tput setaf 4)Uptime:$(tput sgr0) $days minutes"
elif [[ "$label" = 'day,' || "$label" = 'days,' ]]; then
-echo " $(tput bold)$(tput setaf 4)Uptime:$(tput sgr0) "$days $day_label, $hours $hour_label
+ echo " $(tput bold)$(tput setaf 4)Uptime:$(tput sgr0) $days $day_label, $hours $hour_label"
elif [ "$label" = '2' ]; then
-echo " $(tput bold)$(tput setaf 4)Uptime:$(tput sgr0) "$days "hours"
-fi
-
-
-if [ x"$KDE_FULL_SESSION" = x"true" ]; then
- DE='KDE'
- ver=$(kde-open -v | awk '/Platform/ {print $4}')
-elif [ "$DESKTOP_SESSION" = 'cinnamon' ]; then
- DE='Cinnamon'
-elif [ "$DESKTOP_SESSION" = 'unity' ]; then
- DE='Unity'
-elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then
- DE='GNOME'
- ver=$(gnome-session --version | awk {'print $2'})
-elif [ "$DESKTOP_SESSION" = 'LXDE' ]; then
- DE='LXDE'
-elif xprop -root _DT_SAVE_MODE | grep -qs ' = \"xfce4\"$'; then
- DE='XFCE'
-elif [ "$DESKTOP_SESSION" = 'mate' ]; then
- DE='Mate'
-elif [ "$DESKTOP_SESSION" = 'openbox' ]; then
- DE='Openbox'
-
-else
- DE='Not Found'
+ echo " $(tput bold)$(tput setaf 4)Uptime:$(tput sgr0) $days hours"
fi
-echo " $(tput bold)$(tput setaf 4)CPU:$(tput sgr0)" $cpu
-echo " $(tput bold)$(tput setaf 4)Total RAM:$(tput sgr0)" $ram "$(tput bold)$(tput setaf 4)Mb$(tput sgr0)"
-echo " $(tput bold)$(tput setaf 4)Desktop Enviroment:$(tput sgr0)" $DE $ver
-echo " $(tput bold)$(tput setaf 4)Logged in as:$(tput sgr0)" $user
-echo " $(tput bold)$(tput setaf 4)Kernel:$(tput sgr0)" $kernel
-echo " $(tput bold)$(tput setaf 4)Resolution:$(tput sgr0)" $res "$(tput bold)$(tput setaf 4)pixels$(tput sgr0)"
-echo " $(tput bold)$(tput setaf 4)Load Averages:$(tput sgr0)" $load
-echo ""
-echo ""
-#echo " Screenshot being taken.....$(tput bold)$(tput setaf 4)Smile!!$(tput sgr0) (Disabled)"
-#echo ""
-# import -window root $HOME/Screenshot_$(/bin/date +%Y%m%d.%H%M).png
-# echo "Screenshot Saved as " $HOME/Screenshot_$(/bin/date +%Y%m%d.%H%M).png
+echo " $(tput bold)$(tput setaf 4)CPU:$(tput sgr0)$cpu"
+echo " $(tput bold)$(tput setaf 4)Total RAM:$(tput sgr0) $ram $(tput bold)$(tput setaf 4)Mb$(tput sgr0)"
+echo " $(tput bold)$(tput setaf 4)Desktop Enviroment:$(tput sgr0) $de $ver"
+echo " $(tput bold)$(tput setaf 4)Logged in as:$(tput sgr0) $user"
+echo " $(tput bold)$(tput setaf 4)Kernel:$(tput sgr0) $kernel"
+echo " $(tput bold)$(tput setaf 4)Resolution:$(tput sgr0) $res $(tput bold)$(tput setaf 4)pixels$(tput sgr0)"
+echo " $(tput bold)$(tput setaf 4)Load Averages:$(tput sgr0)$load"
+echo
+echo
+# print_screenshot
+# echo
+# echo
[/CODE]

[b]PS:[/b] Attaching the patched version of the script in a zip file was not my choice. Apparently Neowin won't let me attach anything with the .tar.gz or .tar.lzma extension.

I screwed up. I created a Linux Mint 14 virtual machine on my more powerful machine and installed every desktop environment detected by my last patch for testing purposes. Although I tested the desktop environment dection aspect of the script fairly thoroughly, I didn't test the logos I added at all.

When I tested this script on my latop a few minutes ago, I discovered that the Debian logo didn't print correctly. Then I tested the other logos and discovered that some of them failed to print correctly too. Additionally, apparently the processor information in /proc/cpuinfo is not terribly similar between CPU architectures. It looks close to the same for most Intel and AMD CPUs, but it is completely different on the PowerPC and ARM CPUs that I tested. Therefore I wrote a new version of my previous patch that solves both of those issues.

The patch posted below was created against stats 0.8.1, not my previously patched version. The complete new version of the script is attached to this post.


--- stats.sh.orig 2012-12-04 16:18:57.000000000 -0500
+++ stats.sh 2012-12-05 23:00:00.039778198 -0500
@@ -1,119 +1,337 @@
#!/bin/bash
-clear
-
-
-echo ""
-#echo " ___"
-#echo " ,g@@@@@@@@@@@p, "
-#echo " ,@@@@@@@@@@@D****4@@. "
-#echo " ,@@@@@@@@@@P' '%@. "
-#echo " y@@@@@@@@@@F ,g@@p. !3@k "
-#echo " !@@@@@@@@@@@. !@@@@@@@@@@@@k "
-#echo " :@@@@@@@@@@@@ J@@@@@@@@@@@@@L "
-#echo " J@@@@@@@@@*** '***@@@@@@@@@@) "
-#echo " J@@@@@@@@@ @@@@@@@@@@) "
-#echo " J@@@@@@@@@@@@ J@@@@@@@@@@@@@L "
-#echo " J@@@@@@@@@@@@ J@@@@@@@@@@@@F "
-#echo " J@@@@@@@@@@@F {@@@@@@@@@@@F "
-#echo " J@@@E. ''*^' i@@@@@@@@@@B^ "
-#echo " J@@@@@._ ,@@@@@@@@@@P' "
-#echo " J@@@@@@@@@@@@@@@@@@BP*' "
-#echo ""
-echo ""
-
-
-
-
-os=$(cat /etc/*-release | grep "^PRETTY_NAME=" | sed -r 's/PRETTY_NAME="?([^"]+)"?/\1/')
-host=$(uname -n)
-kernel=$(uname -r)
-# get the uptime data
-days=$(uptime | awk '{print $3}' | sed 's/,//g')
-hours=$(uptime | awk '{print $5}' | sed 's/,//g')
-label=$(uptime | awk '{print $4}')
-totalram=$(awk '/MemTotal/{print $2}' /proc/meminfo)
-ram=$((totalram/1024))
-user=$(whoami)
-res=$(xdpyinfo | grep dimensions | awk {'print $2'})
-load=$(uptime | awk -F 'load average:' '{ print $2 }')
-cpu=$(cat /proc/cpuinfo | grep "model name" | sed -r 's/model name"?([^"]+)"?:/\1/' | head -n 1)
-
-
-if [ -z "$os" ]
-then
-echo " $(tput bold)$(tput setaf 4)OS:$(tput sgr0) Not Found"
-else
-echo " $(tput bold)$(tput setaf 4)OS:$(tput sgr0)" $os
-fi
-
-echo " $(tput bold)$(tput setaf 4)Hostname:$(tput sgr0)" $host
-
-
-# get the uptime data
-
-days=$(uptime | awk '{print $3}' | sed 's/,//g')
-hours=$(uptime | awk '{print $5}' | sed 's/,//g')
-label=$(uptime | awk '{print $4}')

+# Copyright (c) 2012, Haggis
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met :
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+# * Neither the name of any individual or organization nor the names of its
+# contributors may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# ( INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+########################################################################
+# Global Variables #
+########################################################################
+
+unset os # Human-readable (pretty) name of the operating system
+unset host # Hostname
+unset kernel # Linux kernel build string
+
+unset days # Days the system has been online
+unset hours # Hours the system has been online (in relation to days)
+unset label # Precision of days, hours, minutes, or seconds
+unset day_label # day/days
+unset hour_label # hour/hours
+
+unset totalram # Size of installed RAM in kilabytes
+unset ram # Size of installed RAM in megabytes
+unset user # Name of the user running this script
+unset res # Resolution of the current X session
+unset load # Load average since the last reboot
+unset cpu # CPU identifier information
+
+unset de # Desktop environment (or window manager) running
+unset ver # DE version information, if available
+
+########################################################################
+# Primary Functions #
+########################################################################
+
+# Print a pretty logo for the Linux distribution the user is running.
+function print_logo
+{
+ id="$(cat /etc/*-release | grep -E '^ID[ ]*=[ ]*[A-Za-z]+[ ]*' | cut -d '=' -f 2)"
+ case $id in
+ ubuntu)
+ echo " "
+ echo " ..''''''.. "
+ echo " .;::::::::::::::;. "
+ echo " .;::::::::::::::'.':::;. "
+ echo " .;::::::::;,'..';. .::::;. "
+ echo " .:::::::,.,. ....:::::::. "
+ echo " .:::::::. :;::::,. .:::::::. "
+ echo " ;:::::: .::::::::::. ::::::; "
+ echo " :::. .' ::::::::::::...,:::::: "
+ echo " :::. .' ::::::::::::...,:::::: "
+ echo " ;:::::: .::::::::::. ::::::; "
+ echo " .:::::::. :,;::;,. .:::::::. "
+ echo " .:::::::;.;. ....:::::::. "
+ echo " ;::::::::;,'..';. .::::; "
+ echo " .;::::::::::::::'.':::;. "
+ echo " .,::::::::::::::,. "
+ echo " ...''''... "
+ echo " "
+ ;;
+ mint)
+ echo ' '
+ echo '.:::::::::::::::::::::::::;,. '
+ echo ',0000000000000000000000000000Oxl, '
+ echo ',00, ..,cx0Oo. '
+ echo ',00, ,,. .cO0o '
+ echo ',00l,,. `00; .. .. .k0x '
+ echo '`kkkkO0l `00; ck000Odlk000Oo. .00c'
+ echo ' d0k `00; x0O:.`d00O;.,k00. x0x'
+ echo ' d0k `00; .00x ,00o ;00c d0k'
+ echo ' d0k `00; .00d ,00o ,00c d0k'
+ echo ' d0k `00; .00d ,00o ,00c d0k'
+ echo ' d0k `00; ;;` .;;. .cc` d0k'
+ echo ' d0O .00d ... d0k'
+ echo ' ;00, :00x:,,,, ..... d0k'
+ echo ' o0O, .:dO000k........... d0k'
+ echo ' :O0x, x0k'
+ echo ' :k0Odc,`.................;x00k'
+ echo ' .;lxO0000000000000000000000k'
+ echo ' ......................'
+ echo ' '
+ ;;
+ fedora)
+ echo ' '
+ echo ' ___ '
+ echo ' ,g@@@@@@@@@@@p, '
+ echo ' ,@@@@@@@@@@@D****4@@. '
+ echo ' ,@@@@@@@@@@P` `%@. '
+ echo ' y@@@@@@@@@@F ,g@@p. !3@k '
+ echo ' !@@@@@@@@@@@. !@@@@@@@@@@@@k '
+ echo ' :@@@@@@@@@@@@ J@@@@@@@@@@@@@L '
+ echo ' J@@@@@@@@@*** `***@@@@@@@@@@) '
+ echo ' J@@@@@@@@@ @@@@@@@@@@) '
+ echo ' J@@@@@@@@@@@@ J@@@@@@@@@@@@@L '
+ echo ' J@@@@@@@@@@@@ J@@@@@@@@@@@@F '
+ echo ' J@@@@@@@@@@@F {@@@@@@@@@@@F '
+ echo ' J@@@E. ``*^` i@@@@@@@@@@B^ '
+ echo ' J@@@@@._ ,@@@@@@@@@@P` '
+ echo ' J@@@@@@@@@@@@@@@@@@BP*` '
+ echo ' '
+ ;;
+ debian)
+ echo ' '
+ echo ' _,met$$$$$gg. '
+ echo ' ,g$$$$$$$$$$$$$$$P. '
+ echo ' ,g$$P$$ $$$Y$$.$. '
+ echo ' ,$$P` `$$$. '
+ echo ' ,$$P ,ggs. `$$b: '
+ echo ' d$$` ,$P$` . $$$ '
+ echo ' $$P d$` , $$P '
+ echo ' $$: $$. - ,d$$` '
+ echo ' $$; Y$b._ _,d$P` '
+ echo ' Y$$. .`$Y$$$$P$` '
+ echo ' `$$b $-.__ '
+ echo ' `Y$$b '
+ echo ' `Y$$. '
+ echo ' `$$b. '
+ echo ' `Y$$b. '
+ echo ' `$Y$b._ '
+ echo ' `$$$$ '
+ echo ' '
+ ;;
+ *)
+ echo ' '
+ echo ' .88888888:. '
+ echo ' 88888888.88888. '
+ echo ' .8888888888888888. '
+ echo ' 888888888888888888 '
+ echo ' 88| _`88|_ `88888 '
+ echo ' 88 88 88 88 88888 '
+ echo ' 88_88_::_88_:88888 '
+ echo ' 88:::,::,:::::8888 '
+ echo ' 88`:::::::::``8888 '
+ echo ' .88 `::::` 8:88. '
+ echo ' 8888 `8:888. '
+ echo ' .8888` `888888. '
+ echo ' .8888:.. .::. ...:`8888888:. '
+ echo ' .8888.| :| `|::`88:88888 '
+ echo ' .8888 ` `.888:8888. '
+ echo ' 888:8 . 888:88888 '
+ echo ' .888:88 .: 888:88888: '
+ echo ' 8888888. :: 88:888888 '
+ echo ' `.::.888. :: .88888888 '
+ echo ' .::::::.888. :: :::`8888`.:. '
+ echo ' ::::::::::.888 | .:::::::::::: '
+ echo ' ::::::::::::.8 | .:8::::::::::::. '
+ echo ' .::::::::::::::. .:888::::::::::::: '
+ echo ' :::::::::::::::88:.__..:88888:::::::::::` '
+ echo ' ``.:::::::::::88888888888.88:::::::::` '
+ echo ' ``:::_:` -- `` -`-` ``:_::::`` '
+ echo ' '
+ ;;
+ esac
+}
+
+# Take a screenshot and save it in the user's home directory.
+function print_screenshot
+{
+ echo " Screenshot being taken.....$(tput bold)$(tput setaf 4)Smile!!$(tput sgr0)"
+ echo
+ import -window root "$HOME/Screenshot_$(/bin/date +%Y%m%d.%H%M).png"
+ echo " Screenshot Saved as $HOME/Screenshot_$(/bin/date +%Y%m%d.%H%M).png"
+}
+
+# Collect release information.
+function get_release
+{
+ os=$(cat /etc/*-release | grep "^PRETTY_NAME=" | sed -r 's/PRETTY_NAME="?([^"]+)"?/\1/')
+ [ -z "$os" ] && os='Not Found'
+ host=$(uname -n)
+ kernel=$(uname -r)
+}
+
+# Save the uptime at the time this function is executed.
+function get_uptime
+{
+ # Since uptime changes constantly, save it before parsing so the output is consistent.
+ current_uptime="$(uptime)"
+ # Parse the uptime snapshot.
+ days=$(echo $current_uptime | awk '{print $3}' | sed 's/,//g')
+ if [ "$days" = 1 ]; then
+ day_label='day'
+ else
+ day_label='days'
+ fi
+ hours=$(echo $current_uptime | awk '{print $5}' | sed 's/,//g')
+ if [ "$hours" = 1 ]; then
+ hour_label='hour'
+ else
+ hour_label='hours'
+ fi
+ label=$(echo $current_uptime | awk '{print $4}')
+}
+
+# Collect generic system statistics.
+function get_system_stats
+{
+ totalram=$(awk '/MemTotal/{print $2}' /proc/meminfo)
+ ram=$((totalram/1024))
+ user=$(whoami)
+ res=$(xdpyinfo | grep dimensions | awk {'print $2'})
+ load=$(uptime | awk -F 'load average:' '{ print $2 }')
+ # AFAIK there is no standard identification strings between CPU architectures.
+ case $(arch) in
+ x86_64|i386|i486|i586|i686)
+ cpu="$(cat /proc/cpuinfo | grep 'model name' | head -n 1 | cut -d ':' -f 2-)"
+ ;;
+ ppc)
+ cpu="$(cat /proc/cpuinfo | grep -E '^cpu' | head -n 1 | cut -d ':' -f 2-)"
+ cpu="${cpu} @$(cat /proc/cpuinfo | grep -E '^clock' | head -n 1 | cut -d ':' -f 2-)"
+ ;;
+ arm*)
+ cpu=$(cat /proc/cpuinfo | grep 'Processor' | head -n 1 | cut -d ':' -f 2-)
+ ;;
+ *)
+ cpu='Unknown'
+ ;;
+ esac
+}
+
+# Determine which desktop environment the user is running.
+function get_desktop_environment
+{
+ # $DESKTOP_SESSION in an UNRELIABLE method for determining which
+ # desktop environment is running. It is tied to the display manager,
+ # not the desktop environment itself. It is useful, though, when it
+ # is set.
+ if [ -z "$DESKTOP_SESSION" ]; then
+ if [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}kdeinit')" ]; then
+ DESKTOP_SESSION='kde-plasma'
+ elif [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}cinnamon')" ]; then
+ DESKTOP_SESSION='cinnamon'
+ elif [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}unity')" ]; then
+ DESKTOP_SESSION='unity'
+ elif [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}gnome-session')" ]; then
+ DESKTOP_SESSION='gnome'
+ elif [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}lxsession')" ]; then
+ DESKTOP_SESSION='LXDE'
+ elif [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}xfce.*-session')" ]; then
+ DESKTOP_SESSION='xfce'
+ elif [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}mate-session')" ]; then
+ DESKTOP_SESSION='mate'
+ elif [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}openbox')" ]; then
+ DESKTOP_SESSION='openbox'
+ elif [ -n "$(ps xo cmd | grep -v 'grep' | grep -E '([/][A-Za-z]+)*[/]{0,1}fluxbox')" ]; then
+ DESKTOP_SESSION='fluxbox'
+ fi
+ fi
+
+ if [ -n "$KDE_FULL_SESSION" ]; then
+ de='KDE'
+ ver=$(kde-open -v | awk '/Platform/ {print $4}')
+ elif [ "$DESKTOP_SESSION" == 'cinnamon' ]; then
+ de='Cinnamon'
+ ver=$(cinnamon --version | cut -d ' ' -f 2)
+ elif [ "$DESKTOP_SESSION" == 'ubuntu' ]; then
+ de='Unity'
+ ver=$(unity --version | cut -d ' ' -f 2)
+ elif [ -n "$GNOME_DESKTOP_SESSION_ID" ]; then
+ de='GNOME'
+ ver=$(gnome-session --version | awk {'print $2'})
+ elif [ "$DESKTOP_SESSION" == 'LXDE' ]; then
+ de='LXDE'
+ ver=$(lxpanel --version | cut -d ' ' -f 2)
+ elif [ "$DESKTOP_SESSION" == 'xfce' ]; then
+ de='XFCE'
+ ver=$(xfce4-session --version | head -n 1 | cut -d ' ' -f 2)
+ elif [ "$DESKTOP_SESSION" == 'mate' ]; then
+ de='Mate'
+ ver=$(mate-session --version | cut -d ' ' -f 2)
+ elif [ "$DESKTOP_SESSION" == 'openbox' ]; then
+ de='Openbox'
+ ver=$(openbox --version | head -n 1 | cut -d ' ' -f 2)
+ elif [ "$DESKTOP_SESSION" == 'fluxbox' ]; then
+ de='Fluxbox'
+ ver=$(fluxbox -version | head -n 1 | cut -d ' ' -f 2)
+ else
+ de='Not Found'
+ fi
+}
+
+########################################################################
+# Main #
+########################################################################

+clear

-
-
-if [ "$days" = 1 ]; then
-day_label='day'
-else
-day_label='days'
-fi
-
-#format labels
-if [ $hours = 1 ]; then
-hour_label='hour'
-else
-hour_label='hours'
-fi
-
-#format output
+get_release
+get_uptime
+get_system_stats
+get_desktop_environment
+
+echo
+print_logo
+echo
+echo " $(tput bold)$(tput setaf 4)OS:$(tput sgr0) $os"
+echo " $(tput bold)$(tput setaf 4)Hostname:$(tput sgr0) $host"
if [ "$label" = 'min,' ]; then
-echo " $(tput bold)$(tput setaf 4)Uptime:$(tput sgr0) "$days "minutes"
+ echo " $(tput bold)$(tput setaf 4)Uptime:$(tput sgr0) $days minutes"
elif [[ "$label" = 'day,' || "$label" = 'days,' ]]; then
-echo " $(tput bold)$(tput setaf 4)Uptime:$(tput sgr0) "$days $day_label, $hours $hour_label
+ echo " $(tput bold)$(tput setaf 4)Uptime:$(tput sgr0) $days $day_label, $hours $hour_label"
elif [ "$label" = '2' ]; then
-echo " $(tput bold)$(tput setaf 4)Uptime:$(tput sgr0) "$days "hours"
-fi
-
-
-if [ x"$KDE_FULL_SESSION" = x"true" ]; then
- DE='KDE'
- ver=$(kde-open -v | awk '/Platform/ {print $4}')
-elif [ "$DESKTOP_SESSION" = 'cinnamon' ]; then
- DE='Cinnamon'
-elif [ "$DESKTOP_SESSION" = 'unity' ]; then
- DE='Unity'
-elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then
- DE='GNOME'
- ver=$(gnome-session --version | awk {'print $2'})
-elif [ "$DESKTOP_SESSION" = 'LXDE' ]; then
- DE='LXDE'
-elif xprop -root _DT_SAVE_MODE | grep -qs ' = \"xfce4\"$'; then
- DE='XFCE'
-elif [ "$DESKTOP_SESSION" = 'mate' ]; then
- DE='Mate'
-elif [ "$DESKTOP_SESSION" = 'openbox' ]; then
- DE='Openbox'
-
-else
- DE='Not Found'
+ echo " $(tput bold)$(tput setaf 4)Uptime:$(tput sgr0) $days hours"
fi
-echo " $(tput bold)$(tput setaf 4)CPU:$(tput sgr0)" $cpu
-echo " $(tput bold)$(tput setaf 4)Total RAM:$(tput sgr0)" $ram "$(tput bold)$(tput setaf 4)Mb$(tput sgr0)"
-echo " $(tput bold)$(tput setaf 4)Desktop Enviroment:$(tput sgr0)" $DE $ver
-echo " $(tput bold)$(tput setaf 4)Logged in as:$(tput sgr0)" $user
-echo " $(tput bold)$(tput setaf 4)Kernel:$(tput sgr0)" $kernel
-echo " $(tput bold)$(tput setaf 4)Resolution:$(tput sgr0)" $res "$(tput bold)$(tput setaf 4)pixels$(tput sgr0)"
-echo " $(tput bold)$(tput setaf 4)Load Averages:$(tput sgr0)" $load
-echo ""
-echo ""
-#echo " Screenshot being taken.....$(tput bold)$(tput setaf 4)Smile!!$(tput sgr0) (Disabled)"
-#echo ""
-# import -window root $HOME/Screenshot_$(/bin/date +%Y%m%d.%H%M).png
-# echo "Screenshot Saved as " $HOME/Screenshot_$(/bin/date +%Y%m%d.%H%M).png
+echo " $(tput bold)$(tput setaf 4)CPU:$(tput sgr0)$cpu"
+echo " $(tput bold)$(tput setaf 4)Total RAM:$(tput sgr0) $ram $(tput bold)$(tput setaf 4)Mb$(tput sgr0)"
+echo " $(tput bold)$(tput setaf 4)Desktop Enviroment:$(tput sgr0) $de $ver"
+echo " $(tput bold)$(tput setaf 4)Logged in as:$(tput sgr0) $user"
+echo " $(tput bold)$(tput setaf 4)Kernel:$(tput sgr0) $kernel"
+echo " $(tput bold)$(tput setaf 4)Resolution:$(tput sgr0) $res $(tput bold)$(tput setaf 4)pixels$(tput sgr0)"
+echo " $(tput bold)$(tput setaf 4)Load Averages:$(tput sgr0)$load"
+echo
+echo
+# print_screenshot
+# echo
+# echo
[/CODE]

The output of the script on my laptop looks something like this (the logo looks a little messed up because its not in a monospaced font):

[CODE]


_,met$$$$$gg.
,g$$$$$$$$$$$$$$$P.
,g$$P$$ $$$Y$$.$.
,$$P` `$$$.
,$$P ,ggs. `$$b:
d$$` ,$P$` . $$$
$$P d$` , $$P
$$: $$. - ,d$$`
$$; Y$b._ _,d$P`
Y$$. .`$Y$$$$P$`
`$$b $-.__
`Y$$b
`Y$$.
`$$b.
`Y$$b.
`$Y$b._
`$$$$

OS: Debian GNU/Linux wheezy/sid
Hostname: ZIPPYZEBRA
CPU: 7447A, altivec supported @ 1499.999000MHz
Total RAM: 1007 Mb
Desktop Enviroment: Openbox 3.5.0
Logged in as: xorangekiller
Kernel: 3.2.0-4-powerpc
Resolution: 1280x854 pixels
Load Averages: 1.41, 0.75, 0.54


[/CODE]

stats-V0.8.1-xorangekiller2.zip

cool i will have a look at this later

i really need to learn how to regex properly

i.e.


grep -E '([/][A-Za-z]+)*[/]{0,1}kdeinit')
[/CODE]

Regular expressions are [i]very[/i] useful. The one you quoted is checking for any string containing [i]kdeinit[/i] with an optional absolute path in front of it. Although regex is slightly different between the various tools/languages that implement it, it is mostly the same. My favourite regex reference page is here, but you should really read the grep man page for the specific implementation in grep.

[b]PS:[/b] You are welcome to use the patched script I posted above as-is. I assigned copyright to you.

Thanks

i will be adding credits type thing in for all the help you guys have given me while this makes its way to a public release

i am working on Top processes now

really enjoying doing this

I noticed a couple posts up that you are considering adding command line switches to control the script's behavior. A good way to accept switches in basically any order or combination in BASH can be done using a switch case like in the code snippet below.


# Parse the given arguments.
while [ $# -gt 1 ]; do
case $1 in
--noverify)
noverify=1
;;
--format)
format=1
;;
--verbose|-v)
verbose=1
;;
--help)
usage
exit 0
;;
*)
echo "Invalid Argument -- $1"
usage
exit 1
;;
esac
shift
done

# Get the action to take.
action="$1"
[ -z "$action" ] && action='default'

# Execute the function associated with that action.
eval $action
[/CODE]

If you don't want to use an eval system or have any required arguments, check that [i]$#[/i] is greater than 0 instead of 1 and don't use any of the code I posted after the loop exits. I hope that helps a little; I know I had trouble writing a good argument parser when I first started with BASH.

  • Like 1
  • 2 months later...

can get it here

disabled the logos until i can get it working right on 64bit

you can enable them by removing the # next to print_logo lol

http://haggistech.co.uk/stats-V1.1.tar.gz

  • 5 months later...

Not touched this for a wee while, not really touched anything computer related actually for a while lol

 

will get back into it tonight though

 

anyone still using it?

I know there are a lot of scripts out there to do this sort of thing on Linux, but I wanted to support another Neowin member so I have been using it. If you look at the screenshots I posted in this thread a couple days ago, you might notice that I used your script in the second one. Keep up the great work!
 

P.S. Haggis, if you get the point where you are very comfortable with the stability and features of your script, I am willing to contribute Debian packaging so you can provide .deb files for Debian and Ubuntu. This is an open offer. Don't hesitate to ask me, even if you don't reach that point for months.

Not touched this for a wee while, not really touched anything computer related actually for a while lol

 

will get back into it tonight though

 

anyone still using it?

 

Still using it but having to modify it a bit for Linux Mint 15.

 

The 'screenfetch' on Mint's forums lacks in appearances so I much prefer yours.

Still using it but having to modify it a bit for Linux Mint 15.

 

The 'screenfetch' on Mint's forums lacks in appearances so I much prefer yours.

 

 

what are you having to modify?

I know there are a lot of scripts out there to do this sort of thing on Linux, but I wanted to support another Neowin member so I have been using it. If you look at the screenshots I posted in this thread a couple days ago, you might notice that I used your script in the second one. Keep up the great work!

 

P.S. Haggis, if you get the point where you are very comfortable with the stability and features of your script, I am willing to contribute Debian packaging so you can provide .deb files for Debian and Ubuntu. This is an open offer. Don't hesitate to ask me, even if you don't reach that point for months.

 

 

Awesome

 

I fixed the "No LSB Modules are available"

Haggis, on 28 Aug 2013 - 23:02, said:

what are you having to modify?

 

Detection for Cinnamon (Commented out DESKTOP_ENVIRONMENT line before the if..elseif)

Changed from ID to DISTRIB_ID to pick up Mint rather than Ubuntu

Some colour formatting for the mint logo

Changed import to gnome-screenshot as import doesn't handle transparency in Cinnamon and isn't a default package in Ubuntu/Mint

 

Haggis, on 28 Aug 2013 - 23:10, said:

Awesome

 

I fixed the "No LSB Modules are available"

 

I had to install standard unix tools then run it via "bash stats.sh" to fix that as it defaults to dash for sh on Ubuntu.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I'm reading the reports as EU rejecting Apple's proposal because Trusted System Agent would be an intermediary offered to third party AI's (this article is also worded as such) but Siri AI itself would not pass this intermediary. This would cause a situation where Siri AI would have more direct system access and offer it an unfair advantage. (speaking from EU regulator perspective here) Apple is citing security issues with doing what EU asked for, and I think this also supports this theory, because truly direct system access like Siri AI would make it impossible to control third party AI's running on the devices and e.g. reign them in via adjustments to Trusted System Agent. So, I _think_ this is the sticking point right now: EU saying they need to be on equal footing as Siri AI, Apple saying they can't be because Apple only trusts their own AI. Apple could of course be leaning a bit extra hard towards this because they're biased. One method to find an agreement would be to have Siri AI also run through Trusted System Agent and treat it as untrusted. This kind of defensive architecture design (especially when involving an AI) would honestly not be a very bad idea from a sheer engineering standpoint. But then Apple would need to swallow their pride and adapt worldwide due to EU, and make perhaps major updates delaying Siri AI once more.
    • I have not even heard of that game. will take a look
    • Chasys Photo 5.41.01 by Razvan Serea Chasys Photo is a suite of image editing applications including a layer-based image editor with adjustment layers, linked layers, timeline and frame-based animation, icon editing, image stacking and comprehensive plug-in support (Chasys Photo Editor), a fast image viewer (Chasys Photo Viewer) and a fast multi-threaded image file converter (Chasys Photo Converter) , with RAW image support in all components. It supports the native file formats of several competitors including Adobe Photoshop, Affinity Photo, ArtWeaver, Corel PhotoPaint, FireAlpaca, GIMP, Krita, Paint.NET, PaintShop Pro and Pixlr, and the whole suite is designed to make effective use of multi-core processors, touch-screens and pen-input devices. Designed under the mantra of “unique, flexible and powerful”, Chasys Photo takes a radically different approach to image editing with the aim of opening up new possibilities for those who dare to be different. Chasys Photo key features: Free-style layering with blending modes Adjustment layers with multiple adjustments per layer Linked layers (a.k.a Linked Smart Objects) Composite, Image List, Frame Animation and Object Animation image modes Animation, both frame-based and object-based (timeline animation) Animation Composer engine Image Stacking for noise reduction, super-resolution, etc. Tablet/Pen-input/Stylus support with pressure control Touch-screen support with gestures including pitch-to-zoom and multi-finger panning Support for the native formats of Adobe Photoshop, Affinity Photo, ArtWeaver, Corel PhotoPaint, FireAlpaca, GIMP, Krita, Paint.NET, PaintShop Pro and Pixlr Support for common formats such as JPEG, animated PNG, animated GIF, TIFF, PICT, WebP, HEIF, DDS, JPEG-2000, JPEG-XR, JPEG-XL, AVI video, etc. Support for the OpenRaster interchange file format and rare formats such as QOI, MNG/JNG and DPX Support for older formats such as PPM/PGM/PBM, PCX/DCX, PCD, TGA, COKE, etc. Comprehensive Camera RAW file support with live adjustment Extensive plug-in support with streamlined SDKs Support for Photoshop Filter Plug-ins (.8BF) Advanced printing and scanning engines PDF document generation Icon and cursor editing, import and export, including Vista-style and Mac-OS icons Screen Capture, including Video Screen Capture with multiple triggering modes Video capture from devices (e.g. TV/Video) Supports multi-core processors, High-DPI displays and Multiple Display setups Integrated File Browser, Bluetooth OBEX and in-built utilities (Calculator, Notepad) Shell integration with thumbnails and conflict detection Unlimited Undo/Redo and Asynchronous Auto-Save, with Just-in-time memory compression to save space Fully re-editable text with advanced styling and effects (TextArt) Full alpha channel through out the workflow with Alpha protection (a.k.a. transparency protection) Multiple language support with user-editable language files and translation assistant (Chasys Photo Language Studio) Anti-aliasing and super-sampling support in tools and paths* Smart-resizing (similar to seam-carving) Best-in-class post-edit heuristics anti-aliasing engine Physical measurement specification with display size detection via EDID Uses the latest CD5 specification with animation and multi-resolution Super-fast internal graphics engine (JpDRAW2) Full UNICODE support in all components Metadata save, restore and scale to imitate vector art Configurable Guides and Grids with Snap-to-Grid Smart-dither to custom palette Asynchronous preview rendering engine Pantone equivalent palettes for PMS 100 to 814-2x Automatic color naming ... and many more! Chasys Photo 5.41.01 changelog: New Features Layered images with multiple pages (Composite/Multi-page) Additional templates to support template-centric workflow New Layer Blend Mode: Inverse Luma Mask Horizon detection in Rotate Transform Cropping option when importing video Orientation options in QR Code Generator plug-in Solved angle ambiguities (CCW versus CW) Internal Improvements Improved graphics engine (JpDRAW2™ v26.05) Improved CD5 codec (v4.10, improved ACSC compression) Improved interpolation when downsizing images Improved motion detection in Video Capture Slightly lower memory usage (RAM is getting expensive!) File Support and Bug Fixes Improved PXZ file support (placeholders, blanks) [bug-fix] Memory leak in flt_JPEG.dll Download: Chasys Photo 5.41.01 | 46.1 MB (Freeware) View: Chasys Photo Home Page | Wikipedia Page | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • We don't need stars for the word, just use the word "CSAM"
  • Recent Achievements

    • Very Popular
      Captain_Eric earned a badge
      Very Popular
    • One Month Later
      amusc earned a badge
      One Month Later
    • One Month Later
      DJC50PLUS earned a badge
      One Month Later
    • Week One Done
      DJC50PLUS earned a badge
      Week One Done
    • Proficient
      Eric Biran went up a rank
      Proficient
  • Popular Contributors

    1. 1
      +primortal
      508
    2. 2
      PsYcHoKiLLa
      220
    3. 3
      ATLien_0
      92
    4. 4
      +Edouard
      90
    5. 5
      Steven P.
      83
  • Tell a friend

    Love Neowin? Tell a friend!