Self-challenge to report disks like Windows

Reported need:


Challenge to self:

See what I can do, so …

The following is a snapshot of what I was able to come up with:

As can be seen from the end of my script, the intent was to use YAD’s HTML capability to present that as a pop-up, but, my version on UbuntuMATE 22.04 LTS doesn’t seem to work. I do plan to test it on my UbuntuMATE 26.04 test install soon.

So … maybe someone can turn this into an actual Panel App, if the HTML can be easily wrapped into some other tool generator. :slight_smile:


I offer below the SHELL script used to create that HTML page. Admittedly, it is a hack, but I think it is decent enough!

  • I used the supplied image to create my own transparent icon for the “basic” drive.

  • I used the SVG icon artwork for the Ubuntu MATE roundel, so that “conditions” used to validate the OS type, it goes thru a case statement to choose which icon to overlay to represent that OS.

  • I did not incorporate logic for network drives because I don’t have any, but I looked at the tools to do so, and if someone would share a report for some commands to have the output that would be parsed, I could work out that additional logic to handle the case for network-mounted drives as well.


Artwork Ref:


    [Edit:   revised logic for portability]

Script:   Devices__ReportDiskStatus.sh

#!/bin/bash

### 
###	VERSION 1 - Prototype with conceptual constructs
###
###	VERSION 2 - Logic modified for proper self-contained initialization
###
### VERSION 3 - removed he sudo commands associated with wget
###
###	VERSION 4 - icon cache re-defined under User HOME directory
###

populateIcons()
{
	roundel_MATE_icon="${icons}/Ubuntu__MATE_Roundel.svg"

	if [ ! -s "${roundel_MATE_icon}" ]
	then
		###	Only perform test if icons not at expected location
		if [ ! -d "${icons}" ]
		then
			mkdir -v "${icons}" 2>&1 | awk '{ printf("\t %s\n", $0 ) }'
			if [ -d "${icons}" ]
			then
				chmod -v 775 "${icons}" 2>&1 | awk '{ printf("\t %s\n", $0 ) }'
				chown -v ${primaryUserID} "${icons}" 2>&1 | awk '{ printf("\t %s\n", $0 ) }'

				echo -e "\n\t CONFIRMED: Setup ... required icon repository created at '${icons}' ..."
				ls -ld "${icons}" | awk '{ printf("\t %s\n", $0 ) }'
			else
				echo -e "\n\t Unable to create required icon repository at '${icons}'. Unable to proceed.\n" ; exit 1
			fi
		fi

		roundel_MATE_url="https://upload.wikimedia.org/wikipedia/commons/0/07/Ubuntu_MATE_rondel_logo.svg"
		wget -q "${roundel_MATE_url}" -O- | tee "${roundel_MATE_icon}" >/dev/null

		if [ -s "${roundel_MATE_icon}" ]
		then
			echo -e "\n\t CONFIRMED: Setup ... required icon saved at '${roundel_MATE_icon}' ..."
			ls -l "${roundel_MATE_icon}" | awk '{ printf("\t %s\n", $0 ) }'
		else
			echo -e "\n\t Unable to download required icon from the master source location [${roundel_MATE_url}]. Unable to proceed.\n" ; exit 1
		fi
	fi

	roundel_UBUNTU_icon="${icons}/Ubuntu__Standard_Roundel.svg"

	if [ ! -s "${roundel_UBUNTU_icon}" ]
	then
		roundel_UBUNTU_url="https://upload.wikimedia.org/wikipedia/commons/a/ab/Logo-ubuntu_cof-orange-hex.svg"
		wget -q "${roundel_UBUNTU_url}" -O- | tee "${roundel_UBUNTU_icon}" >/dev/null

		if [ -s "${roundel_UBUNTU_icon}" ]
		then
			echo -e "\n\t CONFIRMED: Setup ... required icon saved at '${roundel_UBUNTU_icon}' ..."
			ls -l "${roundel_UBUNTU_icon}" | awk '{ printf("\t %s\n", $0 ) }'
		else
			echo -e "\n\t Unable to download required icon from the master source location [${roundel_UBUNTU_url}]. Unable to proceed.\n" ; exit 1
		fi
	fi

	###
	###	FUTURES:  Add additional logic to download icons representing the other OS flavours.
	###

	###
	###	Install the basic drive icon that is used
	###
	echo "iVBORw0KGgoAAAANSUhEUgAAADAAAAAlCAYAAAAEGWqvAAABhWlDQ1BJQ0MgcHJvZmlsZQAAKJF9kb9Lw0AcxV9/iKIVBwuKOGSoThakFXHUKhShQqgVWnUwufQXNGlIUlwcBdeCgz8Wqw4uzro6uAqC4A8Q/wBxUnSREr+XFFrEeHDch3f3HnfvAH+jwlQzOAmommWkkwkhm1sVul8RRB+GEEdMYqY+J4opeI6ve/j4ehflWd7n/hz9St5kgE8gnmW6YRFvEE9vWjrnfeIwK0kK8TnxhEEXJH7kuuzyG+eiw36eGTYy6XniMLFQ7GC5g1nJUImniCOKqlG+P+uywnmLs1qpsdY9+QtDeW1lmes0R5HEIpYgQoCMGsqowEKUVo0UE2naT3j4Rxy/SC6ZXGUwciygChWS4wf/g9/dmoV4zE0KJYCuF9v+GAO6d4Fm3ba/j227eQIEnoErre2vNoCZT9LrbS1yBAxsAxfXbU3eAy53gOEnXTIkRwrQ9BcKwPsZfVMOGLwFetfc3lr7OH0AMtRV6gY4OATGi5S97vHuns7e/j3T6u8H1Exyzg7r/gAAAAAGYktHRAC2ALIAdYBx6QYAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfqBAwABC8L4HNhAAAAGXRFWHRDb21tZW50AENyZWF0ZWQgd2l0aCBHSU1QV4EOFwAAAoBJREFUWMPtWLuO2kAUPX7MWEJii2iLlWgYabUNNit+IFKQKLajSaR8SpKfSJRvCBVgGxIqlg2p2W/YJlSrwCoKkVCAmyIxMbO2MWCTxqexZN+ZOWfmzL1XBjJkOAjKrgPevntPjDEoipIoESLCw8MUb16/UlITMLj5QkIIqJqWym6ulkvc3d2h+uxpbF5q3MDrwZCKKZIHAFXTUBQC1zdDSlRAf/CZikJAS5G8B03TUCwKdLqfKBEBjtslIQR0XT/axdR1HSXThNv5SAcJsN0OmVYZus6Onl10naFkWnDcLu0loG27ZJllMHZ88h4YYzBNC7bToZ0EtNoOWeUyGP9/5NciOIdpWWjZDsUS0GzZZJUvwRjfp0ykAs4NWNYlmm2bIutAvV6n2WwGoj9xiqKAiNZP/zv5u78gRRaegNigdeQxq9UK+XweuVwOjUZjPclGaimVSuj1eo+IyFU3aLEwkfIc20jLm+KPmUwmqFarm5c9KIUFCQgSFBUTRXoX0bJIwzDCBRiGkXixCrPFvuMjBTDG4DVqnvL5kznuX95jMV/grH0G45uROKmok5bjOOfhAjjnkDvN6fMprl5c4fbXLcaLMS4+XER2lGE+DiO77X7Jl16uS7rch8gKWY7h5OcJtK8aGNjGBEEE0oK3VqwT8OPUOUXzexNLZYnz4XloZY5rq0PtJ/dkj05AthD/wWG51r+FGUKPeJulorJLVMbyx8tJJtJCUR7dx0J+0kHPMPH+sVsFHNK8bbPHofYBAFVVwwUoigIhBMbjceILJ3GBC4VCdBYajUao1WqoVCqxe5pdd5yIoKpq7A3x5vDG9Pv97FdMhgwZMmTIkCHDX/wGM4dl7bE7Le4AAAAASUVORK5CYII=" |
	base64 -d > "${device}"

	if [ -s "${device}" ]
	then
		echo -e "\n\t CONFIRMED: Setup ... required icon saved at '${device}' ..."
		ls -l "${device}" | awk '{ printf("\t %s\n", $0 ) }'
	fi
}

getUsage()
{
	# Get infor for individual disk
	lsblk --output-all --pairs --paths ${drive} | sed 's+["][ ]+"\n+g' >${devDat}

	# Get partition label & path
	#dPath=$(echo "${dDat}" | awk '{ print $1 }' )
	dPath=$(grep '^PATH' ${devDat} | cut -f2 -d\" )

	#dName=$(echo "${dDat}" | awk '{ print $NF }' )
	dName=$(grep '^LABEL' ${devDat} | cut -f2 -d\" )
	if [ "$(df -h ${dPath} | grep '^/dev/sd' | awk '{ print $6 }' )" = "/" ]
	then
		test ${dbg} -eq 1 && echo "root" >&2
		dName="/"
	fi

	# Get disk capacity in GB
	#vals=$(echo "${dDat}" | awk '{ cnt=length($2) ; printf("%s %s\n", substr( $2, 1, cnt-1), substr( $2, cnt) ) ; }' )
	vals=$(grep '^FSSIZE' ${devDat} | cut -f2 -d\" | awk '{ cnt=length($1) ; printf("%s %s\n", substr( $1, 1, cnt-1), substr( $1, cnt) ) ; }' )
	dSiz=$(echo ${vals} | awk '{ print $1 }' )
	dUniS=$(echo ${vals} | awk '{ print $2 }' )

	# Get disk usage as percentage
	#dUse=$(echo "${dDat}" | awk '{print $5}' | tr -d '%')
	dUse=$(grep '^FSUSE%' ${devDat} | cut -f2 -d\" | tr -d '%' )

	# Get free space
	#vals=$(echo "${dDat}" | awk '{ cnt=length($4) ; printf("%s %s\n", substr( $4, 1, cnt-1), substr( $4, cnt) ) }' )
	vals=$(grep '^FSAVAIL' ${devDat} | cut -f2 -d\" | awk '{ cnt=length($1) ; printf("%s %s\n", substr( $1, 1, cnt-1), substr( $1, cnt) ) ; }' )
	dFree=$(echo ${vals} | awk '{ print $1 }' )
	dUniF=$(echo ${vals} | awk '{ print $2 }' )
	#dFree=$(echo "${dDat}" | awk '{print $4}')
}

colourUsage()
{
	# Define color based on usage percentage
	if [ "${dUse}" -lt 50 ]; then
		statColour="green"
	elif [ "${dUse}" -lt 85 ]; then
		statColour="orange"
	else
		statColour="red"
	fi
}


getOpSysType()
{
	test ${dbg} -eq 1 && test -n "${testor}" && { echo ${testor} >&2 ; }
	#/etc/X11/default-display-manager
	#	/usr/sbin/arctica-greeter
	#	/usr/sbin/lightdm
	#	/usr/sbin/lightdm-gtk-greeter
	#	/usr/sbin/slick-greeter
	#
	#	# cd /home ; cat ${primaryUserID}/.dmrc
	#	[Desktop]
	#	Session=mate
	#
	#	# primaryUserSession=$( eval grep '^Session=' ~${primaryUserID}/.dmrc | cut -f2 -d"=" )
	#	mate

	case "${testor}" in
		"mate" )
			#Ubuntu MATE
			flavIcon="file://${roundel_MATE_icon}"
			#/usr/share/xsessions/mate.desktop
			;;
		"ubuntu" | "gnome" )
			#Ubuntu Desktop
			flavIcon="file://${roundel_UBUNTU_icon}"
			#/usr/share/wayland-sessions/gnome.desktop
			#/usr/share/xsessions/gnome.desktop
			;;
		"kde-plasma" | "kubuntu" )
			#Kubuntu
			flavIcon=""
			#/usr/share/wayland-sessions/plasma.desktop
			#/usr/share/xsessions/plasma.desktop
			;;
		"Lubuntu*" | "LXDE*" )
			#Lubuntu
			#/usr/share/xsessions/lubuntu.desktop
			#/usr/share/xsessions/lxqt.desktop
			flavIcon=""
			;;
		"xubuntu" )
			#Xubuntu
			flavIcon=""
			#/usr/share/xsessions/xubuntu.desktop
			;;
		"budgie-desktop" )
			#Ubuntu Budgie
			flavIcon=""
			;;
		"cinnamon" )
			#Ubuntu Cinnamon
			flavIcon=""
			;;
		"xfce" )
			#Ubuntu Studio
			flavIcon=""
			;;
		"ukui" )
			#Ubuntu Kylin
			flavIcon=""
			;;
		"unity" )
			#Ubuntu Unity
			flavIcon=""
			;;
		* )
			flavIcon=""
			;;
	esac
	test ${dbg} -eq 1 && test -n "${flavIcon}" && { echo ${flavIcon} >&2 ; }
}


getDriveType()
{
	# Logic to be finalized for optional addition
	# of GUI hint of network-based drive

	#findmnt -l -t nfs,nfs4,cifs,smb3,sshfs
	#TARGET                SOURCE                              FSTYPE OPTIONS
	#/mnt/nas              //192.168.1.50/share                cifs   rw,relatime,vers=3.0,iocharset=utf8
	#/home/user/network    192.168.1.10:/volume1/homes         nfs4   rw,relatime,vers=4.1,rsize=131072
	#/mnt/remote           user@host:/home/user                fuse.s rw,nosuid,nodev,relatime,user_id=1000


	#findmnt -D -t nfs,nfs4,cifs,smb3
	#SOURCE                      FSTYPE   SIZE  USED AVAIL USE% TARGET
	#//192.168.1.50/share        cifs     1.8T  1.2T  600G  67% /mnt/nas
	#192.168.1.10:/volume1/homes nfs4     5.4T  2.0T  3.4T  37% /home/user/network

	# Need equivalent lsblk report for an instance of each type of remote mounted filesystem
	#lsblk --output-all --pairs --paths ${drive} | sed 's+["][ ]+"\n+g' >${devDat}

	echo "" >>/dev/null
}


diskHtml()
{
	cat <<-EnDoFfIlE
<div style='width: 280px ; align-items: right ; margin: 0,0,0,0' >

<table style='width: 270px ;' >
        <!-- Container -->
<tr>
<td style='width: 54px ; height: 54px' >

<span style='position: absolute ;
	' >
EnDoFfIlE

	if [ \( "${dName}" = "/" \) -a \( -n "${flavIcon}" \) ]
	then
		cat <<-EnDoFfIlE
	<img style='z-index: 99 ;
		position: relative ;
		top: 0%; left: 0% ;
		transform: translate(50%, -150%) ;
		width: 25px ;
		height: 25px ; ' src="${flavIcon}" >

	<img style='z-index: 1 ;
		position: relative ;
		top: 0%; left: 0% ;
		transform: translate(-63%, -50%) ;
		width: 48px ;
		height: 37px ; ' src="file://${icons}/DRIVE__Local.png" >
</span>
EnDoFfIlE
	else
		cat <<-EnDoFfIlE
	<img style='z-index: 1 ;
		position: relative ;
		top: 0%; left: 0% ;
		transform: translate(0%, -50%) ;
		width: 48px ;
		height: 37px ; ' src="file://${icons}/DRIVE__Local.png" >
</span>
EnDoFfIlE
	fi
	
	cat <<-EnDoFfIlE
</td>

<td>
	<table>
    	<tr>
	<td>
        	<p class="textUpper" > <span class="bigger" >${dName}</span> &nbsp; [${dPath}] &nbsp; ${dUse}%</p>
	</td>
    	</tr>
    	<tr>
	<td>
            	<!-- Bar Bounds -->
        	<div style='width: 200px ;
			background-color: #ddd ;
			margin: 0 ;
			'>
            		<!-- Bar Measure -->
            		<div style='width: ${dUse}% ;
	    			background-color: ${statColour} ;
				height: 15px ;
				text-align: left ;
				line-height: 15px ;
				color: white ;
				font-weight: bold ;
				' >
            		</div>
		</div>
	</td>
    	</tr>
    	<tr>
	<td>
       		<p class="textLower" >${dFree} ${dUniF}B &nbsp; free of &nbsp; ${dSiz} ${dUniS}B</p>
	</td>
    	</tr>
	</table>
</td>
</tr>
</table>
</div>
EnDoFfIlE

}

#####################################################################################
#####################################################################################


dbg=0
dbg=2

# sudo:x:27:ericthered
primaryUserID=$( grep '^sudo:' /etc/group | cut -f4 -d":" | cut -f1 -d"," )
if [ -z "${primaryUserID}" ]
then
	echo -e "\n\t Unable to identify the Primary User ID.  Unable to proceed.\n" ; exit 1
fi
	
base=$(basename "${0}" ".sh" )

displayHtml="/home/${primaryUserID}/Downloads/${base}_report.html"
devDat="/home/${primaryUserID}/Downloads/${base}_driveRaw.txt"

icons="/home/${primaryUserID}/.config/icons"
device="${icons}/DRIVE__Local.png"


###
###	Initialize graphics
###

populateIcons


# HTML and CSS for the progress bar
rm -f ${displayHtml}

	#margin:		0, 0, 1px, 0 ;
echo "
<html>
<head>

<style type="text/css" >

div {
	margin: 0px ;
	padding: 0px ;
	border-spacing: 0px ;
	background-color: #000 ;
	color:		#eee ;
}

table,tr,td {
	margin: 0px ;
	padding: 1px ;
	border-spacing: 0px ;
	background-color: #000 ;
	color:		#eee ;
}

.textUpper {
	margin:		0 ;
	margin-bottom:	0px ;
	font-family:	Ubuntu ;
	font-size:	12px ;
	font-weight:	normal
	/* padding:	10px ; */
}

.textLower {
	margin:		0 ;
	margin-top:	0px ;
	font-family:	Ubuntu ;
	font-size:	12px ;
	font-weight:	normal
	/* padding:	10px ; */
}

.bigger {
	font-size:	15px ;
	font-weight:	900 
}

.overlay-img {
}

</style>

</head>
<body>
" > ${displayHtml}


first=1

for drive in $(df -h | grep '^/dev/sd' | sort -k1,1 | sort -k6,6 | awk '{ print $1 }' )
do
	test ${first} -eq 0 && { echo "<div style='height: 10px ; width: 280px'></div>" >> ${displayHtml} ; } 

	getUsage

	colourUsage

	flavIcon=""
	if [ "${dName}" = "/" ]
	then
		testor=${GDMSESSION}
		if [ -z "${testor}" ]
		then
			if [ -n "$( ps -e | grep 'mate-session' )" ]
			then
				testor="mate"
			else
				testor="ubuntu"
			fi
		fi

		getOpSysType
	fi


	if [ "${dName}" != "/" ]
	then
		getDriveType
	fi


	diskHtml >> ${displayHtml}

	first=0
done


echo "
</body>
</html>
" >> ${displayHtml}

# Display in YAD
#yad --html --title="Disk Usage" --width=400 --height=150 --center --no-buttons < ${displayHtml}

#sudo -i -u ${primaryUserID} firefox --new-tab ${displayHtml}
#su - ${primaryUserID} -c "firefox --new-tab ${displayHtml}"

echo -e "\n\t GENERATED: Report created as HTML file ..."
ls -l ${displayHtml} | awk '{ printf("\t %s\n", $0 ) }'

6 Likes

For on-demand operation, you can create custom application launcher for a wrapper script. The wrapper script would invoke your html generator and pass html file to a simple html viewer.

Some ideas regarding html viewer can be found here:

P.S. Could not resist to mention

3 Likes

Tried to test device.sh but it looks for /home/ericthered/ stuff

user@cw:~$ . device.sh 
bash: /home/ericthered/Downloads/bash_report.html: No such file or directory
bash: /home/ericthered/Downloads/bash_driveRaw.txt: No such file or directory
grep: /home/ericthered/Downloads/bash_driveRaw.txt: No such file or directory
grep: /home/ericthered/Downloads/bash_driveRaw.txt: No such file or directory
grep: /home/ericthered/Downloads/bash_driveRaw.txt: No such file or directory
grep: /home/ericthered/Downloads/bash_driveRaw.txt: No such file or directory
grep: /home/ericthered/Downloads/bash_driveRaw.txt: No such file or directory
3 Likes

Sorry! I was offering “raw” hack".

I’ve updated the script source code above. It should now be portable. I’ve removed the hardcoded references, except for initial setup (verbose reporting first time).

Let me know if you have issue with the approach.


Session log of first run:
        (updated to reflect most recent code version offered above)

ericthered @ OasisMega1 : ~
$ ~root/Devices__ReportDiskStatus.sh
	 mkdir: created directory '/home/ericthered/.config/icons'
	 mode of '/home/ericthered/.config/icons' retained as 0775 (rwxrwxr-x)
	 ownership of '/home/ericthered/.config/icons' retained as ericthered

	 CONFIRMED: Setup ... required icon repository created at '/home/ericthered/.config/icons' ...
	 drwxrwxr-x 2 ericthered ericthered 4096 Apr 14 13:22 /home/ericthered/.config/icons

	 CONFIRMED: Setup ... required icon saved at '/home/ericthered/.config/icons/Ubuntu__MATE_Roundel.svg' ...
	 -rw-rw-r-- 1 ericthered ericthered 5890 Apr 14 13:22 /home/ericthered/.config/icons/Ubuntu__MATE_Roundel.svg

	 CONFIRMED: Setup ... required icon saved at '/home/ericthered/.config/icons/Ubuntu__Standard_Roundel.svg' ...
	 -rw-rw-r-- 1 ericthered ericthered 699 Apr 14 13:22 /home/ericthered/.config/icons/Ubuntu__Standard_Roundel.svg

	 CONFIRMED: Setup ... required icon saved at '/home/ericthered/.config/icons/DRIVE__Local.png' ...
	 -rw-rw-r-- 1 ericthered ericthered 1193 Apr 14 13:22 /home/ericthered/.config/icons/DRIVE__Local.png

	 GENERATED: Report created as HTML file ...
	 -rw-rw-r-- 1 ericthered ericthered 9811 Apr 14 13:22 /home/ericthered/Downloads/Devices__ReportDiskStatus_report.html

ericthered @ OasisMega1 : ~
$ 

Subsequent runs:

ericthered @ OasisMega1 : ~
$ ~root/Devices__ReportDiskStatus.sh

	 CONFIRMED: Setup ... required icon saved at '/home/ericthered/.config/icons/DRIVE__Local.png' ...
	 -rw-rw-r-- 1 ericthered ericthered 1193 Apr 14 13:24 /home/ericthered/.config/icons/DRIVE__Local.png

	 GENERATED: Report created as HTML file ...
	 -rw-rw-r-- 1 ericthered ericthered 9811 Apr 14 13:24 /home/ericthered/Downloads/Devices__ReportDiskStatus_report.html

ericthered @ OasisMega1 : ~
$ 
2 Likes

yes, I have issues.

I assume the main code starts after the 2 lines of ####### (lines 309,310)

there is an exit 1 (line 320) which closes the terminal

do I have to run it with sudo? I will not.

3 Likes

I just tried at my end with my basic user ID (I usually do most things as root. :slight_smile:

If you remove the “sudo” from the 2 wget instances, the code should be OK, as long as /opt has 777 privileges, otherwise, if you replace the reference to “/opt” with a different path that your userID has access to.

If you have a recommendation for a more standardized location, please let me know.

2 Likes

I will not spend time on this … difficult to follow. It does not run with my $USER

Running as root bypasses security, permissions, and other stuff that can be destructive to a system. If sudo cannot do, something is very wrong. There are less than 0.1% cases where you have to become root (sudo su) in order to fix an issue in the filesystem.

I assume you’re kidding if you run as root, I NEVER do.

2 Likes

During my career, I started as root from almost day one, and never looked back, always being careful of “where I put my foot down”, so to speak. No, I was not joking!

The changes I made (removed the sudo references) worked for my basic user ID, without sudo, but I have 777 on /opt.

That is why, if you have a better target of the “initialization” data store (download and save icons from source URLs), I could code that directly to avoid issues encountered with /opt not being “public”.

2 Likes

I have other stuff in /opt and don’t want to change it to 777.

  1. line 328 icons=“cache_icons” # default home dir, not /opt

  2. remove sudo before tee in 2 lines # sudo not needed

chmod +x device.sh

./device.sh

when the script runs, it creates ~/cache_icons dir, I find 3 files with proper permissions

-rw-rw-r--  1 user user 1193 Apr 14 05:59 DRIVE__Local.png
-rw-rw-r--  1 user user 5890 Apr 14 05:59 Ubuntu__MATE_Roundel.svg
-rw-rw-r--  1 user user  699 Apr 14 05:59 Ubuntu__Standard_Roundel.svg

In ~/Downloads I find 2 files, raw and report.html

report.html looks like (not sure if the icon is correct):

3 Likes

I had to change line 328 to icons=“/home/user/cache_icons” # my home dir.

re-run the script, icon looks right

3 Likes

Thank you for persisting, Pavlos! Much appreciate having an independant confirmation.

I made that change last night, as well, but didn’t get around to updating the above script. That change has been incorporated in the above.


Just curious why the Ubuntu or MATE icon is not displaying over the ROOT drive. Were the SVGs downloaded? or did you block the wget for those?

2 Likes

Eugene, have you reconfirmed that the approach outlined at “Ask Ubuntu” is still workable at UM 22.04 ?

1 Like

Sorry, Eric, I can not confirm anything for sure because that was not my post and I have not tried to reproduce their suggestions myself. On the other hand, their Python scripts require GTK3 which is available at UM 22.04, i.e. it definitely may work. And google-chrome can be started in -app mode still.

3 Likes

I looked at the code, I have the svg files. It seems $testor var looks for my gdmsession, if it is mate or ubuntu or … I tweaked the code a bit and I see the mate logo on top of the disk.

3 Likes

Thank you, Pavlos. Do you mind sharing the modified code segment with us?

2 Likes

I made changes, my version is very compact. If you follow this thread:

  • changed icons location
  • removed sudo before tee

I will try to clean up my code and email it to you.

3 Likes

more testing … it does not list mounted disks

Filesystem        1K-blocks     Used   Available Use% Mounted on
/dev/sda2         229123436 69803456   147608340  33% /
/dev/sda1            523244     6232      517012   2% /boot/efi
//truenas/share 22547641639 93017444 22454624195   1% /home/user/share

the code picked up sda1,2 as I posted before but not the //truenas/share

findmnt is a useful command

findmnt --real -t nosquashfs -o SOURCE,TARGET,FSTYPE,SIZE,USED,AVAIL,USE%

SOURCE          TARGET               FSTYPE        SIZE  USED  AVAIL USE%
/dev/sda2       /                    ext4        218.5G 66.6G 140.8G  30%
portal          ├─/run/user/1000/doc fuse.portal                     
/dev/sda1       ├─/boot/efi          vfat          511M  6.1M 504.9M   1%
//truenas/share └─/home/user/share   cifs           21T 88.7G  20.9T   0%
4 Likes

You teached me a command that I was never aware of.
TNX @pavlos :smiley:

3 Likes

Thank you, Pavlos, but I did point that out in my initial posting.

Was that first report the result from df ?

If not, what was the actual command used for that first report?

Otherwise, would you be willing to share with me the equivalent of the commands:

findmnt -D -t nfs,nfs4,cifs,smb3

and

findmnt -D -t nosquashfs,notmpfs

The first should give only network-mounted drives. The second should give all. In both cases, the pseudo file systems are ignored.

With the output of those two, I will be able to sort out the logic for handling local drives separate from network drives, and present the network drives in a second column.

I was still thinking about it, but I was looking into reporting things like optical drives, cameras, usb sticks & drives as a third category. No decision on whether that third category would be in column 2 or column 3, but distinct from network drives, not lumped into the same column with those.

1 Like

Hi, @tkn :slight_smile:

@pavlos is absolutely right: “findmnt is a useful command! I have to admit that I also didn’t know about findmnt until, maybe 3 years ago, when I learned about it, from a Red Hat Course, but using different options than @pavlos used here and for a different purpose.

Specifically, sudo findmnt --verify checks /etc/fstab for syntax errors and other errors (e.g: missing mountpoints). You can also add the --verbose switch to that specific command to show additional information (apparently --verbose only works with the --verify option / switch, for now, according to the findmnt manpage).

For instance, the following article explains that particular use of findmnt :

How to verify fstab file | sleeplessbeastie’s notes - https://sleeplessbeastie.eu/2019/01/21/how-to-verify-fstab-file/

I hope this helps :slight_smile:

4 Likes