Add a --create-hook option that won't override -a

Addresses #17.
break
noctuid 9 years ago
parent e1c2622301
commit 13a658fde0

@ -57,6 +57,11 @@ Some window managers allow querying what the current monitor is (e.g. bspwm and
See the manpage for more information. See the manpage for more information.
### Hooks
Tdrop provides a `--create-hook` flag that can be used to run a command after first creating the dropdown. A `$1` in the given command will be replaced with the window id for the dropdown (in this case the command will of course need to be in single quotes or the dollar sign escaped). For example, to set a dropdown as always on top, `-c 'wmctrl -i -r $1 -b add,above'` could be added to a tdrop command.
I plan to remove the current `-p`, `-P`, `-M`, and `-O` flags and replace them with generic hooks. Currently these options are only useful for dealing with floating/moving/resizing as they override settings made by `-a`. After this change, the new settings will still be able to be used for this purpose, but the idea is to have tdrop deal with these things automatically using `-a`. I will also provide a way to have the settings for another window manager be used as a simpler initial workaround for tdrop not yet having settings for some window manager.
### Auto-hiding ### Auto-hiding
In addition to creating dropdowns, tdrop can automatically hide a window and later un-hide it. For example, if gvim is opened to write a git commit message from the terminal, tdrop can automatically hide the terminal (dropdown or not) and restore it after the user is finished writing the commit message: In addition to creating dropdowns, tdrop can automatically hide a window and later un-hide it. For example, if gvim is opened to write a git commit message from the terminal, tdrop can automatically hide the terminal (dropdown or not) and restore it after the user is finished writing the commit message:

14
tdrop

@ -26,6 +26,8 @@ options:
-f specify flags/options to be used when creating the term or window (e.g. -f '--title mytitle'; default: none). caution: if there is a tmux/tmuxinator session specified (with -s), the option to execute a program (usually -e for terminal programs) is implicitly added by tdrop! -f specify flags/options to be used when creating the term or window (e.g. -f '--title mytitle'; default: none). caution: if there is a tmux/tmuxinator session specified (with -s), the option to execute a program (usually -e for terminal programs) is implicitly added by tdrop!
-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)
-m for use with multiple monitors and only with dropdowns (not for auto_show or auto_hide); convert percentages used for width or height to values relative to the size of the current monitor and force reszing of the dropdown when the monitor changes (default: false) -m for use with multiple monitors and only with dropdowns (not for auto_show or auto_hide); convert percentages used for width or height to values relative to the size of the current monitor and force reszing of the dropdown when the monitor changes (default: false)
-c cmd provide a command to be run after first creating the dropdown
(e.g. to set some window property)
--clear clear saved window id; useful accidentally make a window a dropdown (e.g. '$ tdrop --clear current') --clear clear saved window id; useful accidentally make a window a dropdown (e.g. '$ tdrop --clear current')
--no-cancel don't cancel auto-showing --no-cancel don't cancel auto-showing
(default is to prevent this when manually toggling a term after it is auto-hidden) (default is to prevent this when manually toggling a term after it is auto-hidden)
@ -55,13 +57,14 @@ map_pre=""
map_post="" map_post=""
unmap_post="" unmap_post=""
oneshot_post="" oneshot_post=""
create_hook=""
dec_fix="" dec_fix=""
program_flags="" program_flags=""
clearwid=false clearwid=false
cancel_auto_show=true cancel_auto_show=true
auto_detect_wm=false auto_detect_wm=false
monitor_aware=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:c:d:f:-:am opt
do do
case $opt in case $opt in
h) height=$OPTARG;; h) height=$OPTARG;;
@ -74,6 +77,7 @@ do
P) map_post=$OPTARG;; P) map_post=$OPTARG;;
M) unmap_post=$OPTARG;; M) unmap_post=$OPTARG;;
O) oneshot_post=$OPTARG;; O) oneshot_post=$OPTARG;;
c) create_hook=$OPTARG;;
d) dec_fix=$OPTARG;; d) dec_fix=$OPTARG;;
f) program_flags=$OPTARG;; f) program_flags=$OPTARG;;
a) auto_detect_wm=true;; a) auto_detect_wm=true;;
@ -100,6 +104,7 @@ do
post-command) map_post=$OPTARG;; post-command) map_post=$OPTARG;;
post-unmap) unmap_post=$OPTARG;; post-unmap) unmap_post=$OPTARG;;
oneshot-post) oneshot_post=$OPTARG;; oneshot-post) oneshot_post=$OPTARG;;
create-hook) create_hook=$OPTARG;;
decoration-fix) dec_fix=$OPTARG;; decoration-fix) dec_fix=$OPTARG;;
program-flags) program_flags=$OPTARG;; program-flags) program_flags=$OPTARG;;
auto-detect-wm) auto_detect_wm=true;; auto-detect-wm) auto_detect_wm=true;;
@ -445,6 +450,12 @@ unmap_post_command() {
fi fi
} }
run_create_hook() {
if [[ -n $create_hook ]]; then
eval "$create_hook"
fi
}
maybe_cancel_auto_show() { maybe_cancel_auto_show() {
if $cancel_auto_show && \ if $cancel_auto_show && \
[[ $1 == $(cat /tmp/tdrop/auto_hidden/wid 2> /dev/null) ]]; then [[ $1 == $(cat /tmp/tdrop/auto_hidden/wid 2> /dev/null) ]]; then
@ -611,6 +622,7 @@ wid_toggle() {
set_geometry_for_monitor "$wid" set_geometry_for_monitor "$wid"
fi fi
fi fi
run_create_hook "$wid"
fi fi
} }

@ -48,6 +48,9 @@ Specify a command to execute after unmapping a dropdown. This can be used with w
\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)
.TP .TP
\fB-c\fR, \fB --create-hook\fR
Specify a command to execute after first creating or initializing a dropdown. Unlike the previous options, this will not override the post or pre commands and can be used for purposes other than floating a window. One possible usage is to set certain window properties for the dropdown. This command can contain a '$1' (single quoted or escaped) which will be replaced with the window id of the dropdown. (default: none)
.TP
\fB\-d\fR, \fB \-\-decoration-fix\fR \fB\-d\fR, \fB \-\-decoration-fix\fR
Specify a window decoration/border size in the form <x decoration size>x<y decoration size> to be taken into account when saving window position. This should not be necessary for most window managers and is only used with 'auto_show', e.g. 'tdrop -d 1x22 auto_show' for blackbox. (default: none) Specify a window decoration/border size in the form <x decoration size>x<y decoration size> to be taken into account when saving window position. This should not be necessary for most window managers and is only used with 'auto_show', e.g. 'tdrop -d 1x22 auto_show' for blackbox. (default: none)
.TP .TP

Loading…
Cancel
Save