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.
This commit is contained in:
Richard Grenville 2012-11-14 18:04:55 +08:00
parent ce7f686f9e
commit fd9c9ba38d
2 changed files with 7 additions and 1 deletions

View File

@ -26,6 +26,7 @@ opacity=
cur= cur=
i= i=
# Read options
while getopts "scn:w:o:" option; do while getopts "scn:w:o:" option; do
case "$option" in case "$option" in
s) wprefix=''; window='' ;; s) wprefix=''; window='' ;;
@ -37,9 +38,14 @@ while getopts "scn:w:o:" option; do
n) wprefix='-name '; window="$OPTARG" ;; n) wprefix='-name '; window="$OPTARG" ;;
w) wprefix='-id '; window="$OPTARG" ;; w) wprefix='-id '; window="$OPTARG" ;;
o) opacity="$OPTARG" ;; o) opacity="$OPTARG" ;;
\?) exit 1;;
esac esac
done done
# Read positional arguments
shift $(($OPTIND - 1))
[ -n "$1" ] && opacity="$1"
# Validate opacity value # Validate opacity value
if [ -z "$opacity" ]; then if [ -z "$opacity" ]; then
echo "No opacity specified." echo "No opacity specified."

View File

@ -6,7 +6,7 @@ compton\-trans \- an opacity setter tool
.SH SYNOPSIS .SH SYNOPSIS
.nf .nf
.B compton-trans [-wncs] [window] -o [opacity] .B compton-trans [-w WINDOW_ID] [-n WINDOW_NAME] [-c] [-s] OPACITY
.fi .fi
.SH DESCRIPTION .SH DESCRIPTION