From ea734d22e2a3f16dd53362cd7d69ee905261a722 Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Fri, 27 Jul 2018 14:52:11 -0400 Subject: [PATCH] Take disk and screen devices from CLI options --- bin/khatus_show | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/bin/khatus_show b/bin/khatus_show index b06ae1f..12263e1 100755 --- a/bin/khatus_show +++ b/bin/khatus_show @@ -6,9 +6,31 @@ BIN=$HOME/bin STATUS_DIR=$HOME/var/run/status STATUS_FILE__WIFI=$STATUS_DIR/wifi STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF=$STATUS_DIR/notified_energy_bellow_half -DISK_IO_DEVICE='dm-1' -DISK_SPACE_DEVICE='/dev/mapper/kubuntu--vg-root' -SCREEN_BRIGHTNESS_DEVICE_NAME='acpi_video0' +while getopts ":b:d:s:" opt +do + case "$opt" in + b) + SCREEN_BRIGHTNESS_DEVICE_NAME="$OPTARG" + ;; + d) + DISK_IO_DEVICE="$OPTARG" + ;; + s) + DISK_SPACE_DEVICE="$OPTARG" + ;; + \?) + echo "Unknown option: $OPTARG" >&2 + exit 1 + ;; + :) + echo "Missing argument for option: $OPTARG" >&2 + exit 1 + ;; + esac +done +if [ "$SCREEN_BRIGHTNESS_DEVICE_NAME" == '' ]; then echo 'Missing -b' >&2; exit 1; fi +if [ "$DISK_IO_DEVICE" == '' ]; then echo 'Missing -d' >&2; exit 1; fi +if [ "$DISK_SPACE_DEVICE" == '' ]; then echo 'Missing -s' >&2; exit 1; fi SCREEN_BRIGHTNESS_DEVICE_PATH="/sys/class/backlight/$SCREEN_BRIGHTNESS_DEVICE_NAME" -- 2.20.1