Update hooks documentation

- More explicitly mention that single quotes should be used to prevent
  variable evaluation
- List hook flags in readme
- Consistently order in the readme and manpage
- Fix typo in manpage (--pre-create-hook -> --post-create-hook)
- Some rewording
performance
noctuid 6 years ago
parent baa61705f6
commit 3aa34f7d21

@ -70,61 +70,77 @@ Some window managers allow querying what the current monitor is (e.g. bspwm and
See the manpage for more information.
** Hooks
Tdrop provides various hook flags that can be used to run commands at various stages during execution. These commands can make use of any internal tdrop variable, such as =$width=, =$height=, =$xoff=, =$yoff=, =$class=, and =$wid=. For example, to set a dropdown as always on top, "-P 'wmctrl -i -r $wid -b add,above'" could be added to a tdrop command.
Tdrop provides hook flags that the user can specify to run commands at various stages during execution. These commands can make use of any global, internal tdrop variable, such as =$width=, =$height=, =$xoff=, =$yoff=, =$class=, and =$wid= (to prevent evaluation of these variables, the user can specify the hook command in single quotes). For example, to set a dropdown as always on top, the user could specify =-P 'wmctrl -i -r $wid -b add,above'=.
Note that for some of the hooks, the window id is not guarunteed to be known (since the window may not have yet been created), so any scripts that make use of these should check if it is defined (pre-map and pre-float; wid will never be known for pre-create).
Note that for =--pre-map-hook= and =--pre-map-float-command=, the window id is not guarunteed to be known (since the window may not have yet been created), so any script that makes use of these flags should first check if =$wid= is defined. The window id will not be defined for =--pre-create-hook= (even for =current=; I can change this if there is a use case for it).
*** Pre Create
*Program* The hook will be run before the program is started.
=-c= / =--pre-create-hook=
*Current* The hook will be run before unmapping the current window.
*Program* The command will run before the program is started.
*Current* The command will run before unmapping the current window.
*Hide and Show* No effect.
*** Post Create
*Program* The hook will be run after the program is started and its window is active.
=-C= / =--post-create-hook=
*Program* The command will run after the program is started and its window is active.
*Current* The hook will be run after unmapping the current window.
*Current* The command will run after unmapping the current window.
*Hide and Show* No effect.
*** Pre Float
A command specifically meant to float the window. Note that if you specify this, it will override any defaults from =-a=.
*** Pre Map
=-p= / =--pre-map-hook=
*Program* / *Current* The command will be run before mapping the window.
*Program* / *Current* / *Show* The command will run before mapping the window.
*Hide* No effect.
*Show* Will be used before mapping the window if it was previously floating.
*** Post Float
A command specifically meant to float the window. Note that if you specify this, it will override any defaults from =-a=.
*** Post Map
=-P= / =--post-map-hook=
*Program* / *Current* The command will be run after mapping the window.
*Program* / *Current* / *Show* The command will run after mapping the window.
*Hide* No effect.
*Show* Will be used after mapping the window if it was previously floating.
*** Pre Unmap
=-u= / =--pre-unmap-hook=
*** Pre Map
*Program* / *Current* / *Show* The command will be run before mapping the window.
*Program* / *Current* / *Hide* The command will run before unmapping the window.
*Hide* No effect.
*Show* No effect.
*** Post Map
*Program* / *Current* / *Show* The command will be run after mapping the window.
*** Post Unmap
=-U= / =--post-unmap-hook=
*Program* / *Current* / *Hide* The command will run after unmapping the window.
*Show* No effect.
*** Pre Float
=-l= / =--pre-map-float-command=
A command specifically meant to float the window. Note that if you specify this, it will override any defaults from =-a=.
*Program* / *Current* The command will run before mapping the window.
*Hide* No effect.
*** Pre Unmap
*Program* / *Current* / *Hide* The command will be run before unmapping the window.
*Show* The command will run before mapping the window only if it was previously floating.
*Show* No effect.
*** Post Float
=-L= / =--post-map-float-command=
*** Post Unmap
*Program* / *Current* / *Hide* The command will be run after unmapping the window.
A command specifically meant to float the window. Note that if you specify this, it will override any defaults from =-a=.
*Show* No effect.
*Program* / *Current* The command will run after mapping the window.
*Hide* No effect.
*Show* The command will run after mapping the window only if it was previously floating.
** 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:

@ -44,8 +44,8 @@ Specify a number (or any extra text) to differentiate between dropdowns of the s
\fB-c COMMAND\fR, \fB --pre-create-hook=COMMAND\fR
Specify a command to execute before first creating or initializing a dropdown (before mapping a normal dropdown or before unmapping the 'current' window). This flag has no effect for the auto_(hide|show) commands. (default: none)
.TP
\fB-C\fR, \fB --pre-create-hook=COMMAND\fR
NDSpecify a command to execute after first creating or initializing a dropdown (after mapping a normal dropdown or after unmapping the 'current' window). This flag has no effect for the auto_(hide|show) commands. (default: none)
\fB-C\fR, \fB --post-create-hook=COMMAND\fR
Specify a command to execute after first creating or initializing a dropdown (after mapping a normal dropdown or after unmapping the 'current' window). This flag has no effect for the auto_(hide|show) commands. (default: none)
.TP
\fB-p COMMAND\fR, \fB --pre-map-hook=COMMAND\fR
Specify a command to execute before showing/mapping a dropdown. Note that this will run when showing a dropdown for the first time even when --pre-create-hook is used. (default: none)
@ -53,18 +53,18 @@ Specify a command to execute before showing/mapping a dropdown. Note that this w
\fB-P COMMAND\fR, \fB --post-map-hook=COMMAND\fR
Specify a command to execute after showing/mapping a dropdown. Note that this will run when hiding a dropdown for the first time even when --post-create-hook is used. (default: none)
.TP
\fB-l COMMAND\fR, \fB --pre-map-float-command=COMMAND\fR
Specify a command execute before showing/mapping a dropdown in order to float the dropdown (e.g. a bspwm oneshot rule). This may be useful if you don't want to float all windows of a given program and tdrop doesn't automatically support this for your window manager with the -a flag. This will override any default floating command when used with -a.
.TP
\fB-L COMMAND\fR, \fB --post-map-float-command=COMMAND\fR
Specify a command execute after showing/mapping a dropdown in order to float the dropdown. This may be useful if you don't want to float all windows of a given program and tdrop doesn't automatically support this for your window manager with the -a flag. This can be used if your window manager does not support floating rules at all; for example, it can be used to fake a key combination (e.g. using xdotool) that will float the current window. This will override any default floating command when used with -a.
.TP
\fB-u COMMAND\fR, \fB --pre-unmap-hook=COMMAND\fR
Specify a command to execute before hiding/unmapping a dropdown. (default: none)
.TP
\fB-U COMMAND\fR, \fB --post-unmap-hook=COMMAND\fR
Specify a command to execute after hiding/unmapping a dropdown. (default: none)
.TP
\fB-l COMMAND\fR, \fB --pre-map-float-command=COMMAND\fR
Specify a command execute before showing/mapping a dropdown in order to float the dropdown (e.g. a bspwm oneshot rule). This may be useful if you don't want to float all windows of a given program and tdrop doesn't automatically support this for your window manager with the -a flag. This will override any default floating command when used with -a.
.TP
\fB-L COMMAND\fR, \fB --post-map-float-command=COMMAND\fR
Specify a command execute after showing/mapping a dropdown in order to float the dropdown. This may be useful if you don't want to float all windows of a given program and tdrop doesn't automatically support this for your window manager with the -a flag. This can be used if your window manager does not support floating rules at all; for example, it can be used to fake a key combination (e.g. using xdotool) that will float the current window. This will override any default floating command when used with -a.
.TP
\fB-d DEC_SIZE\fR, \fB --decoration-fix=DEC_SIZE\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)
.TP

Loading…
Cancel
Save