rename post-map and pre-map commands for clarity

long-opts
angelic-sedition 10 years ago
parent 10b51860d9
commit 1998ca514d

60
tdrop

@ -16,8 +16,8 @@ options:
-y pos specify y offset for a newly created term (default: 1, see BUGS in man) -y pos specify y offset for a newly created term (default: 1, see BUGS in man)
-s name name for tmux or tmuxinator session (if not given, will not use tmux) -s name name for tmux or tmuxinator session (if not given, will not use tmux)
-n num num or extra text; only needed if want multiple dropdowns of same program (default: "") -n num num or extra text; only needed if want multiple dropdowns of same program (default: "")
-p cmd provide a pre command to float the window if necessary -p cmd provide a pre-map command to float the window if necessary
-P cmd provide a post command to float the window if necessary -P cmd provide a post-map command to float the window if necessary
-O cmd provide a one time command only for when a dropdown is created/initiated (useful for 'tdrop -c') -O cmd provide a one time command only for when a dropdown is created/initiated (useful for 'tdrop -c')
-d XxY give decoration/border size to accurately save position; only applicable with auto_show; on applicable with a few window managers (e.g. blackbox) -d XxY give decoration/border size to accurately save position; only applicable with auto_show; on applicable with a few window managers (e.g. blackbox)
-a automatically detect window manager and if settings exist for it, automatically set -p, -P, and -d values as necessary; this can have affect when used with a terminal or with auto_show or auto_hide (default: false) -a automatically detect window manager and if settings exist for it, automatically set -p, -P, and -d values as necessary; this can have affect when used with a terminal or with auto_show or auto_hide (default: false)
@ -45,8 +45,8 @@ width="100%"
height="45%" height="45%"
xoff=0 xoff=0
yoff=1 yoff=1
float_pre="" map_pre=""
float_post="" map_post=""
oneshot_post="" oneshot_post=""
session_name="" session_name=""
num="" num=""
@ -64,8 +64,8 @@ do
y) yoff=$OPTARG;; y) yoff=$OPTARG;;
s) session_name=$OPTARG;; s) session_name=$OPTARG;;
n) num=$OPTARG;; n) num=$OPTARG;;
p) float_pre=$OPTARG;; p) map_pre=$OPTARG;;
P) float_post=$OPTARG;; P) map_post=$OPTARG;;
O) oneshot_post=$OPTARG;; O) oneshot_post=$OPTARG;;
d) dec_fix=$OPTARG;; d) dec_fix=$OPTARG;;
W) normal_window=true;; W) normal_window=true;;
@ -80,8 +80,8 @@ do
y-offset) yoff=$OPTARG;; y-offset) yoff=$OPTARG;;
session) session_name=$OPTARG;; session) session_name=$OPTARG;;
number) num=$OPTARG;; number) num=$OPTARG;;
pre-command) float_pre=$OPTARG;; pre-command) map_pre=$OPTARG;;
post-command) float_post=$OPTARG;; post-command) map_post=$OPTARG;;
oneshot-post) oneshot_post=$OPTARG;; oneshot-post) oneshot_post=$OPTARG;;
decoration-fix) dec_fix=$OPTARG;; decoration-fix) dec_fix=$OPTARG;;
normal-window) normal_window=true;; normal-window) normal_window=true;;
@ -103,23 +103,23 @@ wm_autodetect_settings() {
# floating or position saving setup # floating or position saving setup
if [[ $wm == bspwm ]]; then if [[ $wm == bspwm ]]; then
float_pre() { map_pre() {
bspc rule -a "$1" -o floating=on bspc rule -a "$1" -o floating=on
} }
# floating window managers that may both move and resize a window after unmapping then mapping it # floating window managers that may both move and resize a window after unmapping then mapping it
elif [[ $wm == Openbox ]]; then elif [[ $wm == Openbox ]]; then
# openbox will resize window to be slightly less than the width of the screen when mapping # openbox will resize window to be slightly less than the width of the screen when mapping
# this is necessary when want width to be 100% # this is necessary when want width to be 100%
float_post() { map_post() {
xdotool windowmove "$1" "$xoff" "$yoff" windowsize "$1" "$width" "$height" xdotool windowmove "$1" "$xoff" "$yoff" windowsize "$1" "$width" "$height"
} }
# floating window managers that may both move a window after unmapping then mapping it # floating window managers that may both move a window after unmapping then mapping it
elif [[ $wm == pekwm ]] || [[ $wm == fluxbox ]] || [[ $wm == Blackbox ]]; then elif [[ $wm == pekwm ]] || [[ $wm == fluxbox ]] || [[ $wm == Blackbox ]]; then
float_post() { map_post() {
xdotool windowmove "$1" "$xoff" "$yoff" xdotool windowmove "$1" "$xoff" "$yoff"
} }
elif [[ $wm == i3 ]]; then elif [[ $wm == i3 ]]; then
float_post() { map_post() {
i3-msg floating enable && \ i3-msg floating enable && \
xdotool windowmove "$1" "$xoff" "$yoff" windowsize "$1" "$width" "$height" xdotool windowmove "$1" "$xoff" "$yoff" windowsize "$1" "$width" "$height"
} }
@ -148,28 +148,28 @@ get_class_name() {
xprop -id "$1" WM_CLASS | awk '{gsub(/"/, ""); print $4}' xprop -id "$1" WM_CLASS | awk '{gsub(/"/, ""); print $4}'
} }
float_pre_command() { map_pre_command() {
# a user set option has higher priority # a user set option has higher priority
if [[ -n $float_pre ]]; then if [[ -n $map_pre ]]; then
eval "$float_pre" eval "$map_pre"
# use automatically set function if exists # use automatically set function if exists
elif [[ -n $(type float_pre) ]]; then elif [[ -n $(type map_pre) ]]; then
# needed when creating oneshot rules for programs where cmd differs from actual class name # needed when creating oneshot rules for programs where cmd differs from actual class name
if [[ $1 == "gnome-terminal" ]]; then if [[ $1 == "gnome-terminal" ]]; then
float_pre "Gnome-terminal" map_pre "Gnome-terminal"
else else
float_pre "$1" map_pre "$1"
fi fi
fi fi
} }
float_post_command() { map_post_command() {
if [[ -n $oneshot_post ]] && [[ $1 == oneshot ]]; then if [[ -n $oneshot_post ]] && [[ $1 == oneshot ]]; then
eval "$oneshot_post" eval "$oneshot_post"
elif [[ -n $float_post ]]; then elif [[ -n $map_post ]]; then
eval "$float_post" eval "$map_post"
elif [[ -n $(type float_post) ]]; then elif [[ -n $(type map_post) ]]; then
float_post "$1" map_post "$1"
fi fi
} }
@ -237,19 +237,19 @@ wid_toggle() {
if $exists && [[ $visibility != IsUnviewable ]]; then if $exists && [[ $visibility != IsUnviewable ]]; then
if [[ $visibility == IsUnMapped ]]; then if [[ $visibility == IsUnMapped ]]; then
if [[ $term == current ]]; then if [[ $term == current ]]; then
float_pre_command "$(< /tmp/tdrop/current"$num"_type)" map_pre_command "$(< /tmp/tdrop/current"$num"_type)"
else else
float_pre_command "$term" map_pre_command "$term"
fi fi
xdotool windowmap "$wid" xdotool windowmap "$wid"
float_post_command "$wid" map_post_command "$wid"
maybe_cancel_auto_show "$wid" maybe_cancel_auto_show "$wid"
else else
xdotool windowunmap "$wid" xdotool windowunmap "$wid"
fi fi
else else
# make it # make it
float_pre_command "$term" map_pre_command "$term"
if [[ $term == current ]]; then if [[ $term == current ]]; then
current_create current_create
elif $normal_window; then elif $normal_window; then
@ -257,7 +257,7 @@ wid_toggle() {
else else
term_create term_create
fi fi
float_post_command oneshot map_post_command oneshot
fi fi
} }
@ -336,11 +336,11 @@ auto_show() {
class=$(< /tmp/tdrop/auto_hidden/class) class=$(< /tmp/tdrop/auto_hidden/class)
was_floating=$(< /tmp/tdrop/auto_hidden/geometry) was_floating=$(< /tmp/tdrop/auto_hidden/geometry)
if [[ $was_floating != false ]]; then if [[ $was_floating != false ]]; then
float_pre_command "$class" map_pre_command "$class"
fi fi
xdotool windowmap "$wid" xdotool windowmap "$wid"
if [[ $was_floating != false ]]; then if [[ $was_floating != false ]]; then
float_post_command "$wid" map_post_command "$wid"
set_geometry "$wid" set_geometry "$wid"
fi fi
fi fi

@ -37,10 +37,10 @@ Specify a tmuxinator or tmux session name to start. An existing tmux session has
Specify a number to add when saving dropdown information. Only needed if multiple dropdowns of the same program are wanted. Can also be used for creating multiple different dropdowns on the fly. (default: none) Specify a number to add when saving dropdown information. Only needed if multiple dropdowns of the same program are wanted. Can also be used for creating multiple different dropdowns on the fly. (default: none)
.TP .TP
\fB\-p\fR, \fB \-\-pre-command\fR \fB\-p\fR, \fB \-\-pre-command\fR
Specify a command to execute before showing a dropdown. This may be useful when setting a rule to float all windows of a given type is undesirable. If 'bspwm' is given, the command will be a oneshot bspwm rule to float the specified program and will also work with 'current' and 'auto_show'. (default: none) Specify a command to execute before showing/mapping a dropdown. This may be useful when setting a rule to float all windows of a given type is undesirable. If 'bspwm' is given, the command will be a oneshot bspwm rule to float the specified program and will also work with 'current' and 'auto_show'. (default: none)
.TP .TP
\fB\-P\fR, \fB \-\-post-command\fR \fB\-P\fR, \fB \-\-post-command\fR
Specify a command to execute after showing a dropdown. This may be useful in the case where a window manager does not support floating rules or floating altogether. It can be used, for example, to fake a key combo to float the current window. (default: none) Specify a command to execute after showing/mapping a dropdown. This may be useful in the case where a window manager does not support floating rules or floating altogether. It can be used, for example, to fake a key combo to float the current window. (default: none)
.TP .TP
\fB\-O\fR, \fB \-\-oneshot-post\fR \fB\-O\fR, \fB \-\-oneshot-post\fR
Specify a post command to execute only when first creating or initiating a dropdown. This can be used when turning the current window into a dropdown to float and resize it. (default: none) Specify a post command to execute only when first creating or initiating a dropdown. This can be used when turning the current window into a dropdown to float and resize it. (default: none)

Loading…
Cancel
Save