Exit with an error message if
- A long option that requires an arg is specified without =
- No positional argument is given (for the program name or auto commands)
- A negative width or height is given without -m
- Numeric options do not have a number value
`-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). Long options require using `--opt=<arg>` as opposed to leaving a space. Refer to `tdrop --help` and the manpage for more complete instructions.
*Changes*
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.
**Changes**:
Old users please note that `-W|--normal-window`, `-z|--sleep-terminal`, and `-Z|--sleep-window` are no longer necessary and have been removed.
Old users please note that `-W|--normal-window`, `-z|--sleep-terminal`, and `-Z|--sleep-window` are no longer necessary and have been removed.
Used for hiding/unhiding programs to acheive quake-dropdown-like-functionality. Can create a dropdown window if one does not already exist and provides options to control the intial size and position, e.g. to leave panels visible. When used with a terminal, provides the option to specify the name of a tmuxinator or tmux session to automatically start or attach to.
Used for hiding/unhiding programs to acheive quake-dropdown-like-functionality. Can create a dropdown window if one does not already exist and provides options to control the intial size and position, e.g. to leave panels visible. When used with a terminal, provides the option to specify the name of a tmuxinator or tmux session to automatically start or attach to.
@ -39,7 +41,7 @@ See man page for more details.
}
}
#
#
# Default Options
# Default Options and Option Parsing
#
#
# xdotool can take percentages; cannot take decimal percentages though
# xdotool can take percentages; cannot take decimal percentages though
@ -77,8 +79,15 @@ do
a) auto_detect_wm=true;;
a) auto_detect_wm=true;;
m) monitor_aware=true;;
m) monitor_aware=true;;
-)
-)
if [[ $OPTARG =~ ^(auto-detect-wm|monitor-aware|clear|no-cancel|help)$ ]] || \
[[ $OPTARG == *=* ]]; then
OPTION=${OPTARG%%=*}
OPTION=${OPTARG%%=*}
OPTARG=${OPTARG#*=}
OPTARG=${OPTARG#*=}
else
echo "Long options with args must be written as --opt=val." | \
tee -a /tmp/tdrop/log
exit 1
fi
case $OPTION in
case $OPTION in
height) height=$OPTARG;;
height) height=$OPTARG;;
width) width=$OPTARG;;
width) width=$OPTARG;;
@ -97,10 +106,40 @@ do
clear) clearwid=true;;
clear) clearwid=true;;
no-cancel) cancel_auto_show=false;;
no-cancel) cancel_auto_show=false;;
help) print_help;;
help) print_help;;
*) print_help illegal_opt;;
esac;;
esac;;
*) print_help illegal_opt;;
*) print_help illegal_opt;;
esac
esac
done
done
program=${*:0-1}
# ensure that positional argument exists
if [[ -z $program ]] || [[ $program =~ ^- ]]; then
echo "1 positional argument is required." \
"For help use -h or --help or see the manpage." | \
tee -a /tmp/tdrop/log
exit 1
fi
# require -m for negative width or height
if ! $monitor_aware && [[ $height$width == *-* ]]; then
echo "-m is required to use negative width or height values." | \
tee -a /tmp/tdrop/log
exit 1
fi
# validate options that require number values
if [[ ! $height$width$xoff$yoff =~ ^[0-9%-]*$ ]]; then
echo "The -h, -w, -x, and -y values must be numbers (or percentages)." | \
tee -a /tmp/tdrop/log
exit 1
fi
if [[ -n $dec_fix ]] && [[ ! $dec_fix =~ ^-?[0-9]+x-?[0-9]+$ ]]; then
echo "The decoration fix value must have form 'num'x'num'." \
"The numbers can be negative or zero." | tee -a /tmp/tdrop/log
exit 1
fi
# non-user-settable global vars
# non-user-settable global vars
# necessary to account for differences in geometry/positioning output from xwininfo
# necessary to account for differences in geometry/positioning output from xwininfo