summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/hwmon34
1 files changed, 25 insertions, 9 deletions
diff --git a/bin/hwmon b/bin/hwmon
index 8dac456..7f2f0f4 100755
--- a/bin/hwmon
+++ b/bin/hwmon
@@ -130,12 +130,13 @@ format_power()
print_sensor()
{
- local label="${1}"
- local len=${2}
- local chip="${3}"
- local chips="${4}"
- local element="${5}"
- shift 5
+ local indent=${1}
+ local label="${2}"
+ local len=${3}
+ local chip="${4}"
+ local chips="${5}"
+ local element="${6}"
+ shift 6
local hwmon=
local value=
local i=
@@ -164,7 +165,12 @@ print_sensor()
;;
esac
- printf ' %s:' "${label}"
+ i=0
+ while [ ${i} -lt ${indent} ]; do
+ printf ' '
+ i=$((${i} + 1))
+ done
+ printf '%s:' "${label}"
i=${#label}
while [ ${i} -lt ${len} ]; do
printf ' '
@@ -184,12 +190,14 @@ usage()
'<label>:<chip>/<element>' '<label>:<chip>/<element>'
printf '\n'
printf 'Options:\n'
+ printf ' -i <num> Indent label/value lines with <num> spaces\n'
printf ' -r Print carriage returns instead of line feeds\n'
printf ' -d Enable debugging output\n'
}
main()
{
+ local indent=
local opt=
local chips=
local max_len=
@@ -199,8 +207,16 @@ main()
local chip=
local element=
- while getopts 'rd' opt "${@}"; do
+ indent=0
+ while getopts 'i:rd' opt "${@}"; do
case "${opt}" in
+ 'i')
+ case "${OPTARG}" in *[!0-9]* | '')
+ usage 1>&2
+ return 1
+ esac
+ indent=${OPTARG}
+ ;;
'r') cr=1;;
'd') debug=1;;
'?')
@@ -239,7 +255,7 @@ main()
esac
chip="${sensor%/*}"
element="${sensor##*/}"
- print_sensor "${label}" ${len} \
+ print_sensor ${indent} "${label}" ${len} \
"${chip}" "${chips}" "${element}" || return 1
done