Styling 'inxi' to suit your Destop Manager's colour theme

If you are like me, you are annoyed by the fact that the report generated by "inxi" highlights the "Category" labels, but de-emphasizes the meaningful data generated for each of those.

The below script changes that for three presets:

  • UbuntuMATE (greenish)
  • Ubuntu (orangy)
  • KDE (blueish)

The code logic can be easily modified (in the script included at the bottom) to apply whichever is your preferred colour scheme, once that is identified.

Here is a sample generated for my system, using the command

USER__inxi_ReportColourized.sh --ubuntuMateSpecs

Adding "--ubuntu" to above command line:

Using "--kde" instead of "--ubuntu":

Script (USER__inxi_ReportColourized.sh):

#!/bin/bash

###    REF:   Correct 'SGR' codes can be identified at URL   https://en.wikipedia.org/wiki/ANSI_escape_code

mode=1
scope=1
doHide=0

command="inxi -c 32 -Fm --network-advanced --slots"

while [ $# -gt 0 ]
do
	case "${1}" in
		"--ubuntuMateSpecs" )
			scope=2
			#command="inxi -c 32 -ACDMNSG --memory-short"
			command="inxi -c 32 -ACDMNSG"
			shift
			;;
		"--hide" )
			doHide=1
			shift
			;;
		"--mate" )
			mode=1
			shift
			;;
		"--shortlist" )
			mode=98
			shift
			cases=""
			while [ -z "$( echo "${1}" | grep -v '^-' )" ]
			do
				cases="${cases} ${1}"
				shift
			done
			;;
		"--themes" )
			mode=99
			shift
			;;
		"--ubuntu" )
			mode=2
			shift
			;;
		"--kde" )
			mode=3
			shift
			;;
		* ) printf "\t Invalid parameter used on command line.  Only valid options: [ --default | --shortlist {cases} | --samples ] \n Bye!\n\n" ; exit 1
			;;
	esac
done

if [ ${scope} -eq 1 ] && [ ${doHide} -eq 0 ]
then
	command="${command} -a"
fi

case ${mode} in
	99 )
	###	Generate multiple reports using each of the choices available from built-in colour theme options
	i=1
	while [ $i -lt 43 ]
	do
		printf "\t %2d ...\n" $i >&2
		printf "\n===  c = $i  ===============================================\n"
		inxi -c $i --cpu
		i=$( expr $i + 1 )
	done >inxi__ColorSchemes_Samples_Full.txt
	;;

	98 )
	###	Generate multiple reports using hard-coded custom list of choices from built-in colour theme options
	for i in 1 2 9 12 18 26 32
	do
		printf "\t %2d ...\n" $i >&2
		printf "\n===  c = $i  ===============================================\n"
		inxi -c $i --cpu
	done >inxi__ColorSchemes_Samples_Shortlist.txt
	;;

	1 )
	#inxi -c 32 -F --output xml --output-file $(pwd)/mine.xml ; more mine.xml
	#exit

	${command} |
	awk -v hs="1;34m"  -v hr="1;37m"  -v l1s="1;34m"  -v l1r="0;32m"  -v d2s="1;37m"  -v d2r="1;32m" '{
		if( index( $0, $1 ) == 1 ){
			printf("\n") ;
			gsub( hs, hr, $0 ) ;
		}else{
			if( l1s != "" ){
				gsub( l1s, l1r, $0 ) ;
			} ;
			if( d2s != "" ){
				gsub( d2s, d2r, $0 ) ;
			} ;
		} ;
		print $0
	}'
	;;

	2 )
	${command} |
	awk -v hs="1;34m"  -v hr="1;37m"  -v l1s="1;34m"  -v l1r="0;33m"  -v d2s="1;37m"  -v d2r="1;33m" '{
		if( index( $0, $1 ) == 1 ){
			printf("\n") ;
			gsub( hs, hr, $0 ) ;
		}else{
			if( l1s != "" ){
				gsub( l1s, l1r, $0 ) ;
			} ;
			if( d2s != "" ){
				gsub( d2s, d2r, $0 ) ;
			} ;
		} ;
		print $0
	}'
	;;

	3 )
	${command} |
	awk -v hs="1;34m"  -v hr="1;37m"  -v l1s="1;34m"  -v l1r="0;34m"  -v d2s="1;37m"  -v d2r="1;34m" '{
		if( index( $0, $1 ) == 1 ){
			printf("\n") ;
			gsub( hs, hr, $0 ) ;
		}else{
			if( l1s != "" ){
				gsub( l1s, l1r, $0 ) ;
			} ;
			if( d2s != "" ){
				gsub( d2s, d2r, $0 ) ;
			} ;
		} ;
		print $0
	}'
	;;

esac
echo ""
5 Likes

Works pretty good :slight_smile:

But what about the difference between the real accepted options and the options that the "error message" pretends to be valid ?
(see this "broken down" piece of the case statement)

"--ubuntuMateSpecs" ) ;;
"--hide" );;
"--mate" );;
"--shortlist" );;
"--themes" );;
"--ubuntu" );;
"--kde" );;
* ) printf "\t Invalid parameter used on command line. Only valid options:
[ --default | --shortlist {cases} | --samples ] \n Bye!\n\n" ; exit 1 ;;
1 Like