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
#+END_EXAMPLE
** Other Commands
If =hide_all= is given instead of a program name, tdrop will hide all visible dropdowns.
* Tested With
** Terminals
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() {
echo "
usage: tdrop [options] <program> or 'current' or
one of 'auto_show'/'auto_hide'/'toggle_auto_hide'
usage: tdrop [options] <program> [program options ...]
or 'current'
or one of 'auto_show'/'auto_hide'/'toggle_auto_hide'
or 'hide_all'
options:
-h height specify a height for a newly created term (default: 45%)
-w width specify a width for a newly created term (default: 100%)
@ -177,7 +179,7 @@ if [[ -z $program_flags ]]; then
fi
# 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
echo >&2 "The program should be in PATH and not contain flags." | \
tee -a "$MUTDROP_PATH"/log
@ -844,6 +846,19 @@ auto_show() {
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
# ** Setup
set_wm
@ -860,6 +875,8 @@ elif [[ $program == auto_hide ]]; then
auto_hide
elif [[ $program == auto_show ]]; then
auto_show
elif [[ $program == hide_all ]]; then
hide_all
else
wid_toggle
fi

@ -4,13 +4,16 @@
.SH NAME
Tdrop - make dropdown terminals and windows
.SH SYNOPSIS
tdrop [\fIOPTIONS\fR] [program name or cmd]
tdrop [\fIOPTIONS\fR] [program name or cmd] [program options ...]
.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.
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
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
.br
E.g.

Loading…
Cancel
Save