X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/7a4d6f5ffa594603ef83bc8b0e9945d12e082490..055e663772628e5a2ddb9c056da7222af517d086:/scripts/dfs?ds=inline

diff --git a/scripts/dfs b/scripts/dfs
index 1730b6e..9e02a87 100755
--- a/scripts/dfs
+++ b/scripts/dfs
@@ -1,18 +1,21 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 #   Adapted from Eridan's "fs" (cleanup, enhancements and switch to bash/Linux)
 #   JM,  10/12/2004
 #
 #   Integrated into Lain in september 2013
-#   https://github.com/copycat-killer/lain
+#   https://github.com/lcpz/lain
+
+#   Requires gawk
 
 # -------------------------------------------------------------------------
 #   Decoding options
 # -------------------------------------------------------------------------
-USAGE="Usage: $0 [-h(elp)] | [-n(arrow mode)] | [-w(eb output)]"
+USAGE="Usage: $0 [-h(elp)] | [-n(arrow mode)] | [-w(eb output) | --type=<fstype> | --exclude-type=<fstype>]"
 
 NARROW_MODE=0
 WEB_OUTPUT=0
+DF_OPTIONS=""
 
 while [ $# -gt 0 ]; do
 case "$1" in
@@ -29,6 +32,12 @@ NARROW_MODE=1
 "-w" )
 WEB_OUTPUT=1
 ;;
+--type=*)
+DF_OPTIONS+=" $1"
+;;
+--exclude-type=*)
+DF_OPTIONS+=" $1"
+;;
 * )
 echo $USAGE
 exit
@@ -56,6 +65,9 @@ AWK_COMMAND="/usr/bin/env gawk"
 ;;
 esac
 
+# Add additional df options
+DF_COMMAND+=$DF_OPTIONS
+
 # -------------------------------------------------------------------------
 #   Grabbing "df" result
 # -------------------------------------------------------------------------
@@ -105,7 +117,7 @@ fi
 #   Computing mount point max length
 # -------------------------------------------------------------------------
 MOUNT_POINT_MAX_LENGTH=` \
-											 echo $SORTED_FILE_SYSTEMS_INFO | $AWK_COMMAND -v PATTERN=$PATTERN \
+											 echo "$SORTED_FILE_SYSTEMS_INFO" | $AWK_COMMAND -v PATTERN=$PATTERN \
 											 '
 											 BEGIN       {
 												 mount_point_length_max = 15;
@@ -183,7 +195,7 @@ echo "$SORTED_FILE_SYSTEMS_INFO" | $AWK_COMMAND -v DEBUG=$DEBUG -v PATTERN=$PATT
 					 current_date = strftime ("%d-%m-%Y @ %H:%M:%S", localtime (systime ()));
 					 free_threshold = 10; # %
 
-						 printf ("<!-- DEBUT CONTENU -->\n");
+		  		 printf ("<!-- DEBUT CONTENU -->\n");
 
 					 printf ( \
 							 "<A NAME=\"top\"></A>\n" \
@@ -197,9 +209,9 @@ echo "$SORTED_FILE_SYSTEMS_INFO" | $AWK_COMMAND -v DEBUG=$DEBUG -v PATTERN=$PATT
 							 "<TD ALIGN=LEFT><STRONG>Mount point</STRONG></TD>\n" \
 							 "<TD ALIGN=CENTER><STRONG>%% Usato&nbsp;(<SPAN CLASS=\"titleblue\">*</SPAN>)" \
 							 "&nbsp;-&nbsp;%% Free&nbsp;(<SPAN CLASS=\"titlegreen\">*</SPAN>)</STRONG></TD>\n" \
-							 "<TD ALIGN=CENTER><STRONG>%% Usato</STRONG></TD>\n" \
-							 "<TD ALIGN=CENTER><STRONG>Spazio libero</STRONG></TD>\n" \
-							 "<TD ALIGN=CENTER><STRONG>Spazio totale</STRONG></TD>\n" \
+							 "<TD ALIGN=CENTER><STRONG>%% Used</STRONG></TD>\n" \
+							 "<TD ALIGN=CENTER><STRONG>Free</STRONG></TD>\n" \
+							 "<TD ALIGN=CENTER><STRONG>Total</STRONG></TD>\n" \
 							 "</TR>\n" );
 				 }
 				 else
@@ -210,9 +222,9 @@ echo "$SORTED_FILE_SYSTEMS_INFO" | $AWK_COMMAND -v DEBUG=$DEBUG -v PATTERN=$PATT
 							 printf ("\n%s", narrow_margin);
 						 else
 							 printf ("%-*s", LEFT_COLUMN + 2, "");
-					 print "                                                     Used    Free     Total ";
+					 print "                                                    Used     Free       Total ";
 					 if (! NARROW_MODE)
-						 print "";
+						 print " ";
 				 }
 			 }
 
@@ -350,7 +362,7 @@ $0 ~ PATTERN    {
 #           printf ("stars_number = %d\n", stars_number);
 
 			printf ("|");
-			for (i = 1; i <= stars_number; i++)
+			for (i = 1; i <= stars_number && i <= 49; i++)
 			{
 				printf ("%s", "*");
 			}
@@ -362,22 +374,22 @@ $0 ~ PATTERN    {
 
 			if (total_size > 1 * t_bytes)
 				printf ( \
-						"| %3d%%    %5.1f    %5.1f Tb\n", \
+						"| %3d%%   %6.1f   %6.1f Tb\n", \
 						percentage_occupied, free_size / t_bytes, total_size / t_bytes \
 						);
 			else if (total_size > 1 * g_bytes)
 				printf ( \
-						"| %3d%%    %5.1f    %5.1f Gb\n", \
+						"| %3d%%   %6.1f   %6.1f Gb\n", \
 						percentage_occupied, free_size / g_bytes, total_size / g_bytes \
 						);
 			else if (total_size > 1 * m_byptes)
 				printf ( \
-						"| %3d%%    %5.1f    %5.1f Mb\n", \
+						"| %3d%%   %6.1f   %6.1f Mb\n", \
 						percentage_occupied, free_size / m_bytes, total_size / m_bytes \
 						);
 			else
 				printf ( \
-						"| %3d%%    %5.1f    %5.1f Kb\n", \
+						"| %3d%%   %6.1f   %6.1f Kb\n", \
 						percentage_occupied, free_size / k_bytes, total_size / k_bytes \
 						);
 		}