summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2018-04-26 18:58:13 (EDT)
committer P. J. McDermott <pj@pehjota.net>2018-04-26 18:58:13 (EDT)
commitecdf1aa05271c2b5c33c9fcbb77e39d47f8a669d (patch)
treeab65741576434a2363ddbe675c3d758eb00edf50 /bin
parent49f42ae806dfb176081e9ef2fd7953af4374892f (diff)
downloadfluxbox-ecdf1aa05271c2b5c33c9fcbb77e39d47f8a669d.zip
fluxbox-ecdf1aa05271c2b5c33c9fcbb77e39d47f8a669d.tar.gz
fluxbox-ecdf1aa05271c2b5c33c9fcbb77e39d47f8a669d.tar.bz2
bin/hwmon: Make indentation level configurable
Diffstat (limited to 'bin')
-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