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" | "--default" )
			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: [ --ubuntuMateSpecs ]  [ --themes | --shortlist {cases} ]  [ --hide ]  [ [ --mate | --default ] | --ubuntu | --kde ] \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 ""
6 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 ;;
3 Likes

Very sorry about that, Thom! I corrected my editing oversight, and updated the script in the above posting.

I hope you didn't expect me to allow any/all of the inxi options to be handled by this script, did you?

O please don't be. What I mentioned i pure cosmetic :slight_smile:
It is just that the options mentioned in the errormessage are quite different to the options that are tested for in the same case statement.

Oh no, Ofcourse not :slight_smile:

I only expected that the "Only valid options:
[ --default | --shortlist {cases} | --samples ]" wouldn't be invalid :slight_smile:

[ --ubuntuMateSpecs | --hide | --mate | --shortlist | --themes | --ubuntu | --kde ] do work pretty wel , contrary to what the error message says.

3 Likes

Sorry again. I guess I shouldn't try to fix when I am distracted by holiday spirit! I have corrected that, properly this time. :slight_smile:

3 Likes

Oh nothing wrong with that. May I wish you a merry christmas ? :smiling_face:

1 Like

Ja, en in ruil daarvoor wens ik jou en de jouwen hele fijne kerstdagen en een gelukkig nieuwjaar!

Revisions at this time seemed to have worked well. I've found the command to be a bit long, so I made this simple Makefile which should install it as /usr/bin/inci.

I can't think of any other names, so there's that lol. You can change that here in the following:

PREFIX = /usr/bin

all:
	@echo Run \'make install\' to install Colorized inxi by UM Community.

install:
	@mkdir -p $(PREFIX)
	@cp -p USER__inxi_ReportColourized.sh $(PREFIX)/inci
	@chmod 755 $(PREFIX)/inci

uninstall:
	@rm -rf $(PREFIX)/inci

3 Likes

Merci beaucoup ! Dank je wel ! :smiley:

1 Like

Glad you liked it.

The script's name is in line with my naming convention, which can be seen with

2 Likes