From fd9c9ba38dafde931a43be055930b9f5c43ec40a Mon Sep 17 00:00:00 2001 From: Richard Grenville Date: Wed, 14 Nov 2012 18:04:55 +0800 Subject: [PATCH] Misc: compton-trans: Allow reading opacity from positional arguments - compton-trans: Allow reading opacity value from positional arguments, like the version in master branch. - compton-trans: Quit when meeting an unrecognized option. --- bin/compton-trans | 6 ++++++ man/compton-trans.1 | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/compton-trans b/bin/compton-trans index 4e55775..7576abc 100755 --- a/bin/compton-trans +++ b/bin/compton-trans @@ -26,6 +26,7 @@ opacity= cur= i= +# Read options while getopts "scn:w:o:" option; do case "$option" in s) wprefix=''; window='' ;; @@ -37,9 +38,14 @@ while getopts "scn:w:o:" option; do n) wprefix='-name '; window="$OPTARG" ;; w) wprefix='-id '; window="$OPTARG" ;; o) opacity="$OPTARG" ;; + \?) exit 1;; esac done +# Read positional arguments +shift $(($OPTIND - 1)) +[ -n "$1" ] && opacity="$1" + # Validate opacity value if [ -z "$opacity" ]; then echo "No opacity specified." diff --git a/man/compton-trans.1 b/man/compton-trans.1 index 97b4d34..995ab87 100644 --- a/man/compton-trans.1 +++ b/man/compton-trans.1 @@ -6,7 +6,7 @@ compton\-trans \- an opacity setter tool .SH SYNOPSIS .nf -.B compton-trans [-wncs] [window] -o [opacity] +.B compton-trans [-w WINDOW_ID] [-n WINDOW_NAME] [-c] [-s] OPACITY .fi .SH DESCRIPTION