Add hide_all command

Fixes #60.
master
Fox Kiester 5 years ago
parent 24d61bd266
commit f4f0f34644
No known key found for this signature in database
GPG Key ID: 316E205D6017DBFF

@ -170,6 +170,9 @@ The most useful application of this functionality is probably when opening video
mime ^video, has mpv, X, flag f = tdrop -a auto_hide && mpv -- "$@" && tdrop -a auto_show mime ^video, has mpv, X, flag f = tdrop -a auto_hide && mpv -- "$@" && tdrop -a auto_show
#+END_EXAMPLE #+END_EXAMPLE
** Other Commands
If =hide_all= is given instead of a program name, tdrop will hide all visible dropdowns.
* Tested With * Tested With
** Terminals ** Terminals
These terminals have been tested with tdrop and support the =-s= and =-a= flags unless otherwise specified: These terminals have been tested with tdrop and support the =-s= and =-a= flags unless otherwise specified:

23
tdrop

@ -6,8 +6,10 @@ mkdir -p "$MUTDROP_PATH" -m 700
print_help() { print_help() {
echo " echo "
usage: tdrop [options] <program> or 'current' or usage: tdrop [options] <program> [program options ...]
one of 'auto_show'/'auto_hide'/'toggle_auto_hide' or 'current'
or one of 'auto_show'/'auto_hide'/'toggle_auto_hide'
or 'hide_all'
options: options:
-h height specify a height for a newly created term (default: 45%) -h height specify a height for a newly created term (default: 45%)
-w width specify a width for a newly created term (default: 100%) -w width specify a width for a newly created term (default: 100%)
@ -177,7 +179,7 @@ if [[ -z $program_flags ]]; then
fi fi
# check that the program is not a path and does not contain flags # check that the program is not a path and does not contain flags
if [[ ! $program =~ ^(current|auto_hide|auto_show|toggle_auto_hide)$ ]] && \ if [[ ! $program =~ ^(current|auto_hide|auto_show|toggle_auto_hide|hide_all)$ ]] && \
! type "$program" &> /dev/null; then ! type "$program" &> /dev/null; then
echo >&2 "The program should be in PATH and not contain flags." | \ echo >&2 "The program should be in PATH and not contain flags." | \
tee -a "$MUTDROP_PATH"/log tee -a "$MUTDROP_PATH"/log
@ -844,6 +846,19 @@ auto_show() {
fi fi
} }
# * Hide All
hide_all() {
shopt -s nullglob dotglob
local dropdowns
dropdowns=("$MUTDROP_PATH"/*)
for dropdown in "${dropdowns[@]}"; do
# cat to silence errors
wid=$(cat "$dropdown" 2> /dev/null)
unmap "$wid" 2> /dev/null
done
shopt -u nullglob dotglob
}
# * Main # * Main
# ** Setup # ** Setup
set_wm set_wm
@ -860,6 +875,8 @@ elif [[ $program == auto_hide ]]; then
auto_hide auto_hide
elif [[ $program == auto_show ]]; then elif [[ $program == auto_show ]]; then
auto_show auto_show
elif [[ $program == hide_all ]]; then
hide_all
else else
wid_toggle wid_toggle
fi fi

@ -4,13 +4,16 @@
.SH NAME .SH NAME
Tdrop - make dropdown terminals and windows Tdrop - make dropdown terminals and windows
.SH SYNOPSIS .SH SYNOPSIS
tdrop [\fIOPTIONS\fR] [program name or cmd] tdrop [\fIOPTIONS\fR] [program name or cmd] [program options ...]
.SH DESCRIPTION .SH DESCRIPTION
Tdrop is used for hiding/unhiding programs to acheive quake/dropdown functionality. It can create a dropdown window if one does not already exist or turn the current window into a dropdown on the fly. It provides options to control the intial size and position of dropdowns, for example to leave panels visible or to deal with window borders. When used with a terminal, it provides an option to specify the name of a tmux session to automatically start. It also allows the user to specify arbitrary options/flags to be used when starting programs. It uses window IDs as opposed to classes, so it can be used with multiple windows of the same program. Tdrop is used for hiding/unhiding programs to acheive quake/dropdown functionality. It can create a dropdown window if one does not already exist or turn the current window into a dropdown on the fly. It provides options to control the intial size and position of dropdowns, for example to leave panels visible or to deal with window borders. When used with a terminal, it provides an option to specify the name of a tmux session to automatically start. It also allows the user to specify arbitrary options/flags to be used when starting programs. It uses window IDs as opposed to classes, so it can be used with multiple windows of the same program.
It also has the ability to automatically hide and automatically show dropdowns. For example, it can be used to automatically hide a terminal when opening something from it, e.g. an image viewer, video player, etc. Tdrop can then automatically bring back the terminal whenever the image view, video player, etc. is closed. See the Examples section for more information. It also has the ability to automatically hide and automatically show dropdowns. For example, it can be used to automatically hide a terminal when opening something from it, e.g. an image viewer, video player, etc. Tdrop can then automatically bring back the terminal whenever the image view, video player, etc. is closed. See the Examples section for more information.
.SH Commands .SH Commands
Tdrop expects the name of a program or 'current' (to use the current window) as the last argument to create a dropdown (optionally followed by any flags to that program). Alternatively, it can take one of auto_show, auto_hide, or toggle_auto_hide. Neither functionality is particularly useful called directly from the command line; the former should be bound to a key, and the latter is better used in shell functions/aliases or with a file opener (e.g. in the rifle.conf). Tdrop expects the name of a program or 'current' (to use the current window) as the last argument to create a dropdown (optionally followed by any flags to that program). Alternatively, it can take one of auto_show, auto_hide, toggle_auto_hide, or hide_all. If hide_all is given instead of a program name, tdrop will hide all visible dropdowns.
Tdrop's functionality is not particularly useful called directly from the command line. Commands should either be bound to a key, used in shell functions/aliases, or used with a file opener (e.g. in the rifle.conf).
.SH OPTIONS .SH OPTIONS
.br .br
E.g. E.g.

Loading…
Cancel
Save