Compare commits

...

3 Commits

Author SHA1 Message Date
noctuid 6a6422fb7c Back to how things were but with OPTIND hackery
Addresses #12
9 years ago
noctuid 3ca647bdec Improve handling of arguments that have whitespace
Addresses #12
9 years ago
noctuid 8748745132 Change how long options are handled
This method is more concise, doesn't require the checks the previous
method did, allows for both the --option=value and --option value
syntaxes, and still uses getopts. I'm not sure if there is some good
reason to not pre-parse the arguments in this way though.

Addresses #12
9 years ago

@ -32,9 +32,9 @@ alt + s
```
### Basic Flags
`-s` should only be used for supported terminals and if the user wants to start a tmux or tmuxinator session. `-a` should be used to set up WM specific rules (which are required for the --width, --height, --xoff, and --yoff flags to work properly; see below for supported WMs). Long options require using `--opt=<arg>` as opposed to leaving a space. Refer to `tdrop --help` and the manpage for more complete instructions.
`-s` should only be used for supported terminals and if the user wants to start a tmux or tmuxinator session. `-a` should be used to set up WM specific rules (which are required for the --width, --height, --xoff, and --yoff flags to work properly; see below for supported WMs). Refer to `tdrop --help` and the manpage for more complete instructions.
Tdrop has basic checks to print errors for malformed commands (for example if a long option is used without `=`). If a tdrop command does not work, please run it in a terminal or check `/tmp/tdrop/log` for error messages and consult the manpage before making an issue.
Tdrop has basic checks to print errors for malformed commands (for example to require the positional argument). If a tdrop command does not work, please run it in a terminal or check `/tmp/tdrop/log` for error messages and consult the manpage before making an issue.
**Changes**:

14
tdrop

@ -61,7 +61,7 @@ clearwid=false
cancel_auto_show=true
auto_detect_wm=false
monitor_aware=false
while getopts :h:w:x:y:s:n:p:P:M:O:d:f:-:am opt
while getopts :h:w:x:y:s:n:p:P:M:O:d:f:-:amcCH opt
do
case $opt in
h) height=$OPTARG;;
@ -78,15 +78,17 @@ do
f) program_flags=$OPTARG;;
a) auto_detect_wm=true;;
m) monitor_aware=true;;
c) clearwid=true;;
C) cancel_auto_show=false;;
H) print_help;;
-)
if [[ $OPTARG =~ ^(auto-detect-wm|monitor-aware|clear|no-cancel|help)$ ]] || \
[[ $OPTARG == *=* ]]; then
if [[ $OPTARG == *=* ]]; then
OPTION=${OPTARG%%=*}
OPTARG=${OPTARG#*=}
else
echo "Long options with args must be written as --opt=val." | \
tee -a /tmp/tdrop/log
exit 1
OPTION=$OPTARG
OPTARG=${*:$OPTIND:1}
((OPTIND++))
fi
case $OPTION in
height) height=$OPTARG;;

@ -60,13 +60,13 @@ If there are available settings for the detected window manager for the -p, -P,
\fB\-m\fR, \fB \-\-monitor-aware\fR
This option only applies for dropdowns (not auto-hiding and auto-showing). Specify that width and height percentages should be relative to the current monitor. If the monitor changes, this option will cause a dropdown to be resized to fit the given percentages. A negative argument is also allowed for '-w' and '-y' with this option (e.g. '-m -w -4') in which case the determined value will be that many pixels less than 100% of the screen size. This fixes the problem where 100% width may actually go over the screen due to window borders/decoration. Note that this option assumes xrandr is being used and requires xrandr to work. (default: false)
.TP
\fB \-\-clear\fR
\fB\-c\fR, \fB \-\-clear\fR
Used to clear a saved window id for the given program or 'current' instead of creating a dropdown; takes no argument.
.TP
\fB \-\-no-cancel\fR
\fB\-C\fR, \fB \-\-no-cancel\fR
Specifies that manually re-showing an auto-hidden window with tdrop should not cancel an auto_show; takes no argument. See examples.
.TP
\fB \-\-help\fR
\fB\-H\fR, \fB \-\-help\fR
Print help that is less awesome than this manpage; takes no argument.
.SH EXAMPLES
.SS Making Dropdowns

Loading…
Cancel
Save