From 54673d5a56a6da7b124e35d96a474e24192952ca Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 19 May 2018 02:13:42 -0400 Subject: bin/bright: Add a toggle feature --- diff --git a/bin/bright b/bin/bright index 04c83f5..bda2643 100755 --- a/bin/bright +++ b/bin/bright @@ -39,6 +39,21 @@ inc_b() set_b ${b} } +tog_b() +{ + local b= + + b=$(get_b) + case ${b} in + [0-9] | [1-4][0-9]) + set_b 100;; + [5-9][0-9] | 100) + set_b 0;; + esac + + return 0 +} + usage() { printf 'Usage: %s {|}\n' "${0}" @@ -46,6 +61,7 @@ usage() printf 'Where is any word beginning with (in any case):\n' printf ' * "U" for up\n' printf ' * "D" for down\n' + printf ' * "T" for toggle (between 0 and 100)\n' printf 'And is any integer between 0 and 100 inclusive\n' return 0 @@ -66,6 +82,7 @@ main() case "${dir}" in [Uu]*) inc_b 20;; [Dd]*) inc_b -20;; + [Tt]*) tog_b;; *[!0-9]* | '') usage 1>&2 return 1 -- cgit v0.9.1