Compare commits

..

No commits in common. 'master' and 'performance' have entirely different histories.

@ -1,10 +0,0 @@
name: lint
on: [push, pull_request]
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- name: shellcheck
uses: ludeeus/action-shellcheck@0.1.0

@ -1,5 +1,258 @@
* About
This is a tdrop fork but using an external script xtoolwait (on AUR =xtoolwait-git=).
It was created to support few programs (like suckless tabbed) which doesn't work yet with the upstream version.
* Demos
This is a basic demo where tdrop is used to hide and show a terminal emulator on different desktops/workspaces:
Just don't forget to install xtoolwait, because I basically replaced hundred lines of code with just one call to this utility.
[[http://noctuid.github.io/tdrop/assets/termite.gif]]
This is a basic demo where tdrop is used to turn the current window (emacs) into a dropdown and then hide and show it on different desktops/workspaces:
[[http://noctuid.github.io/tdrop/assets/current.gif]]
* Advantages Over Other Dropdown Terminals
- Supports essentially any terminal or other program of your choice
- Supports many window managers
- Supports turning any window into a dropdown on the fly
- Supports enforcing dropdown sizing and placement (e.g. to prevent panels from being hidden)
- Supports tiled and floating dropdowns
- Supports floating dropdown instances without requiring the user to create a rule to float all program instances (for some window managers that support both tiling and floating)
- Supports using multiple dropdowns of the same program (see =-n=)
- Supports automatically hiding a dropdown when opening a new window from it (and then optionally re-showing the dropdown when the window is closed)
- Supports automatically starting programs and tmux, tmuxinator, or tmuxifier sessions
- Supports automatically resizing dropdowns based on the current monitor's size
- Has hooks for executing user commands
* Requirements
- bash
- basic utilities (probably already installed on linux)
- GNU coreutils (for install, tee, cat, mkdir, head, etc.)
- gawk
- GNU grep
- procps-ng (for pgrep)
- xprop
- xwininfo
- xdotool
Optional:
- xrandr (required for -m)
- tmux (required for -s)
- tmuxinator (optional for -s)
- tmuxifier (optional for -s)
* Installation and Usage
** Installation
Tdrop is in the AUR as =tdrop-git= and is packaged for Void Linux as =tdrop=. It can also be installed by cloning this repo and running ~sudo make install~. One can then bind a key to it (e.g. with sxhkd).
** Basic Sxhkd Example
#+BEGIN_EXAMPLE
# negative -w arg to account for a border width (default: 100%)
alt + s
tdrop -ma -w -4 -y "$PANEL_HEIGHT" -s dropdown termite
#+END_EXAMPLE
The positional argument should be the name of a program in =$PATH= (as opposed to the full path to a program) and should not contain any flags (see =-f= if you want to pass additional flags to the program when running it). It should always be the last argument.
** Basic Flags
=-w= / =--width=, =-h= / =--height=, =-x= / =--xoff=, and =-y= / =--yoff= can be used to set the window size/position. The argument to any of these can be a number (e.g. =-w 800=) or a percentage (e.g. =-w 100%=). Negative numbers correspond to that many pixels less than 100% of the screen width (e.g. =-w -4=).
=-s= / =--session= should only be used for supported terminals and if the user wants to start/attach to a tmux or tmuxinator session.
Tdrop has basic checks to print errors for malformed commands (e.g. to require one positional argument). If a tdrop command does not work, please run it in a terminal or check =/tmp/tdrop/log= for error messages and consult the manpage before making an issue. For more information, see the [[#troubleshooting][Troubleshooting]] section.
*** Changes
Long options can now be used with whitespace instead of requiring a ~=~ (i.e. =--long-opt value= and ~--long-opt=value~ are both fine).
Old users please note that =-W|--normal-window=, =-z|--sleep-terminal=, and =-Z|--sleep-window= are no longer necessary and have been removed. Similarly, the old hook flags (=-p=, =-P=, =-M=, and =-O= as well as =--create-hook= and =--map-hook=) have been replaced with more specific and useful versions.
** Automatic Window Manager Detection (=-a=)
=-a= / =--auto-detect-wm= can be specified to automatically set certain options (=-l=, =-L=, =-d=, and/or =-i=) based on the current window manager. These flags (whether automatically or manually set) may be necessary for tdrop to behave correctly (e.g. they are required for =-w=, =-h=, =-x=, and =-y= to work correctly for tiling window managers with floating support). See the manpage for further details about these flags.
Note that if you've used [[https://tools.suckless.org/x/wmname][wmname]] to change your window manager's name, tdrop will use any settings for that name instead. In this case, you will generally need to specify the real name of your window manager using the =--wm= flag in order for =-a= to work correctly (e.g. if you are using bspwm and have run =wmname LG3D=, you will need to specify =--wm bspwm=).
** Monitor Awareness (=-m=)
=-m= / =--monitor-aware= can be specified to automatically resize the dropdown based on the current monitor's size when percentages are used for =-w= and/or =-h=. This may be helpful for users of multiple monitors who don't want dropdowns spanning across monitors.
This is particularly useful when using a percentage or negative value with =-w=, =-h=, =-x=, and/or =-y=. For example, =-w -4= normally corresponds to a width 4 pixels less than 100% of the screen width (potentially the combined width of multiple monitors). With =-m=, the pixel values are calculated using the dimensions of the current monitor alone. Negative values may be useful when the window manager (possibly due to window decorations) causes a dropdown with =-w 100%= to go over the edge of the screen. The =-m= option will also automatically resize and/or reposition the dropdown when opening it on a different monitor when one or more of the geometry arguments are negative or percentages.
Some window managers allow querying what the current monitor is (e.g. bspwm and i3), but for other window managers, tdrop determines the current monitor based on the position of the active window. For these window managers, if the desktop is empty, tdrop must wait for the dropdown to be created or mapped before getting the monitor info. This may cause a slight delay before the dropdown is properly resized. If =-m= does not work at all or there is a specific way to query for the current monitor in your window manager, please make an issue.
See the manpage for more information.
** Flicker
For some window managers that require a window to be repositioned after re-mapping it, some flicker may be noticeable. This flicker has been mostly fixed for some window managers (e.g. in the Gnome Shell and Cinnamon DEs) and improved for others. It is usually worse on tiling managers where the window must be re-floated every time it is mapped. The way around this is to use rules to either always have the class or name (see =--name=) floated or one-time rules to only float the next instance of a class. For example, since bspwm has oneshot rules and generally doesn't alter the size/position of a window, there isn't any movement flicker.
A more consistent workaround to improve visual flickering regardless of the window manager is to enable fade-in for the compositor. For compton this can be done by setting =fading = true;= and adjusting the =fade-delta= in the =~/.config/compton.conf= accordingly.
** Hooks
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 =--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
=-c= / =--pre-create-hook=
*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
=-C= / =--post-create-hook=
*Program* The command will run after the program is started and its window is active.
*Current* The command will run after unmapping the current window.
*Hide and Show* No effect.
*** Pre Map
=-p= / =--pre-map-hook=
*Program* / *Current* / *Show* The command will run before mapping the window.
*Hide* No effect.
*** Post Map
=-P= / =--post-map-hook=
*Program* / *Current* / *Show* The command will run after mapping the window.
*Hide* No effect.
*** Pre Unmap
=-u= / =--pre-unmap-hook=
*Program* / *Current* / *Hide* The command will run before unmapping the window.
*Show* No effect.
*** 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.
*Show* The command will run before mapping the window only if it was previously floating.
*** Post Float
=-L= / =--post-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 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:
#+BEGIN_EXAMPLE
hide_on_open() {
tdrop -a auto_hide && "$@" && tdrop -a auto_show
}
alias gc='hide_on_open git commit'
#+END_EXAMPLE
The most useful application of this functionality is probably when opening videos, images, etc. in an external program from a file manager like ranger. For example, in the =rifle.conf=:
#+BEGIN_EXAMPLE
mime ^video, has mpv, X, flag f = tdrop -a auto_hide && mpv -- "$@" && tdrop -a auto_show
#+END_EXAMPLE
* Tested With
** Terminals
These terminals have been tested with tdrop and support the =-s= and =-a= flags unless otherwise specified:
- Alacritty
- cool-retro-term
- GNOME terminal (GNOME, Unity, Cinnamon, etc.)
- [[https://github.com/kovidgoyal/kitty][kitty]]
- Konsole (KDE)
- LilyTerm (requires =confirm_to_execute_command 0= in config for =-s= or =-f '-e...'=)
- LXTerminal (LXDE)
- MATE terminal (MATE)
- QTerminal (LXDE)
- Roxterm
- Sakura
- Terminology (Enlightenment)
- Termite
- Tilix (previously terminix)
- tinyterm/minyterm
- URxvt (including urxvtd)
- Xfce4-terminal (XFCE)
- xiate
- XTerm
If your terminal doesn't work with tdrop, feel free to make an issue. Please follow the steps in the [[#troubleshooting][Troubleshooting]] section.
** Window Managers
The primary goal of tdrop is to "just work" with any window manager. The primary differences between how tdrop deals with different window managers is the strategy it takes for floating only the dropdown (as opposed to all instances of the class that the dropdown is). There are three types of window managers as far as tdrop is concerned:
*** Tiling without Floating Support
If your window manager does not support floating, there's nothing to worry about. Binding a key to =tdrop <flags> terminal= should work. Options for resizing and movement that work only with floating window managers are not supported. One can, however, add post-map and post-unmap commands to do something like change the layout to fullscreen when showing a dropdown then revert the layout when hiding the dropdown. Automatic settings exist to do this for the following window managers (=-a=):
- herbstluftwm
*** Floating/Stacking
For floating window managers, tdrop should also generally "just work", but you may need to add the =-a= option for auto-showing to correctly restore the previous geometry.
That said, these are the floating window managers that currently have been tested:
- mutter (gnome shell)
- muffin (cinnamon)
- xfwm4 (xfce)
- metacity (gnome 2)
- marco (mate)
- kwin (kde)
- openbox (lxde)
- compiz (unity)
- pekwm
- fluxbox
- blackbox
- fvwm
- sawfish
- goomwwm
If your dropdown moves out of place when being shown, make an issue, and I will add settings for it.
*** Tiling with Floating Support
These window managers currently will work with =-a= for a floating (instead of tiled) dropdown:
- bspwm (support for versions prior to 0.9.1 was dropped on 2016/09/22)
- i3
- awesome
Awesome support may be buggy; if you encounter problems, please report them.
* Why Not Use wmctrl?
Necessary features don't work on many window managers, including mine.
* Why Not Use wmutils?
Maybe in the future. The only advantage I can see over xdotool is that it can toggle mapping (=mapw -t=), but this wouldn't be used in this script anyway since different code is executed depending on whether or not the window is mapped or unmapped. Also the command names are somewhat cryptic.
* Similar
- [[https://github.com/lharding/lsh-bin/blob/master/drawer][drawer]]
* Troubleshooting
:PROPERTIES:
:CUSTOM_ID: troubleshooting
:END:
** Tdrop does not work with some terminal/program
Please make an issue. Including the following information would help resolve the problem more quickly.
Basic:
- The incorrect behavior: Does the window appear at all? Is the problem that it is not floated correctly in a supported wm? Or is it a feature request for =-a= support?
- Whether things work as expected with a basic =tdrop <terminal>= (no flags) or whether the issue occurs with a specific flag (probably =-s=)
Additional helpful information:
- If the problem only occurs with the =-s= flag, the issue is likely due to the fact that not all terminals have compatible =-e= flags. It would be helpful if information on how the terminal's flag for executing a command works. Is it something other than =-e=? Are quotations required or incorrect ("-e 'command -flags ...'" vs "-e command flags")?
- If the issue is with the dropdown behavior (e.g. tdrop keeps opening new windows for the program), does the program share a PID across all instances (e.g. open several windows and provide the output of =pgrep -l <program>=)? Does the program have a daemon and client?

196
tdrop

@ -6,10 +6,8 @@ mkdir -p "$MUTDROP_PATH" -m 700
print_help() {
echo "
usage: tdrop [options] <program> [program options ...]
or 'current'
or one of 'auto_show'/'auto_hide'/'toggle_auto_hide'
or 'hide_all'
usage: tdrop [options] <program> or 'current' or
one of 'auto_show'/'auto_hide'/'toggle_auto_hide'
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%)
@ -25,15 +23,15 @@ options:
-L cmd provide a command to float the window after it is mapped
-p cmd provide a pre-map command
-P cmd provide a post-map command
-u cmd provide a pre-unmap command -U cmd provide a post-unmap command -d XxY give decoration/border size to accurately restore window
-u cmd provide a pre-unmap command
-U cmd provide a post-unmap command
-d XxY give decoration/border size to accurately restore window
position; only applicable with auto_show
-S cmd can be used to fix saved geometry with auto_hide; see manpage
-i cmd provide a command to detect whether the current window is a
floating window; on applicable with auto_hide
-f flags specify flags/options to be used when creating the term or
window (e.g. -f '--title mytitle'; default: none).
NOTE: This flag is deprecated. Specify flags after the program name
instead. This flag may be removed in the future.
Caution: if there is a tmux session specified (with -s), the option
to execute a program (usually -e for terminal programs) is
implicitly added by tdrop
@ -55,18 +53,15 @@ options:
window a dropdown (e.g. '$ tdrop --clear current')
--no-cancel don't cancel auto-showing (default is to prevent this when
manually toggling a window after it is auto-hidden)
--timeout set the timeout (in seconds) that tdrop will wait for a window
to appear before giving up in case the program fails to start
(default: 10)
--help print help
See man page for more details.
"
}
error() {
echo >&2 "$@" | tee -a "$MUTDROP_PATH"/log
exit 1
if [[ $1 == illegal_opt ]]; then
exit 1
else
exit 0
fi
}
# * Default Options and Option Parsing
@ -93,7 +88,7 @@ dec_fix=
# set in decoration_settings
subtract_when_same=
is_floating=
program_flags=()
program_flags=
clearwid=false
cancel_auto_show=true
auto_detect_wm=false
@ -103,7 +98,6 @@ wm=
user_set_wm=false
class=
name=
timeout=10
while getopts :h:w:x:y:s:n:c:C:l:L:p:P:u:U:d:S:i:f:-:amt opt
do
case $opt in
@ -124,7 +118,7 @@ do
d) dec_fix=$OPTARG;;
S) subtract_when_same=false;;
i) is_floating=$OPTARG;;
f) eval "program_flags=($OPTARG)";;
f) program_flags=$OPTARG;;
a) auto_detect_wm=true;;
m) monitor_aware=true;;
t) pointer_monitor_detection=true;;
@ -157,7 +151,7 @@ do
decoration-fix) dec_fix=$OPTARG;;
no-subtract-when-same) subtract_when_same=false;;
is-floating) is_floating=$OPTARG;;
program-flags) eval "program_flags=($OPTARG)";;
program-flags) program_flags=$OPTARG;;
auto-detect-wm) auto_detect_wm=true;;
monitor-aware) monitor_aware=true;;
pointer-monitor-detection) pointer_monitor_detection=true;;
@ -167,40 +161,40 @@ do
name) name=$OPTARG;;
clear) clearwid=true;;
no-cancel) cancel_auto_show=false;;
timeout) timeout=$OPTARG;;
help) print_help;;
*) error "Unknown option --$OPTION." \
"Use --help to see available flags.";;
*) print_help illegal_opt;;
esac;;
*) error "Unknown option -$OPTARG." \
"Use --help to see available flags.";;
*) print_help illegal_opt;;
esac
done
shift "$((OPTIND-1))"
program=$1
if [[ ${#program_flags[@]} -eq 0 ]]; then
program_flags=("${@:2}")
fi
if [[ -z $program ]]; then
error "Program to run is required as a positional argument." \
"For help use -h or --help or see the manpage."
# check that the program is not a path and does not contain flags
if [[ ! $program =~ ^(current|auto_hide|auto_show|toggle_auto_hide)$ ]] && \
! type "$program" &> /dev/null; then
echo >&2 "The program should be in PATH and not contain flags." | \
tee -a "$MUTDROP_PATH"/log
exit 1
fi
# check that the program is in PATH
if [[ ! $program =~ ^(current|auto_hide|auto_show|toggle_auto_hide|hide_all)$ ]] && \
! type "$program" &> /dev/null; then
error "The program should be in PATH."
if [[ $# -ne 1 ]]; then
echo >&2 "Exactly 1 positional argument is required." \
"For help use -h or --help or see the manpage." | \
tee -a "$MUTDROP_PATH"/log
exit 1
fi
# validate options that require number values
if [[ ! $height$width$xoff$yoff =~ ^[0-9%-]*$ ]]; then
error "The -h, -w, -x, and -y values must be numbers (or percentages)."
echo >&2 "The -h, -w, -x, and -y values must be numbers (or percentages)." | \
tee -a "$MUTDROP_PATH"/log
exit 1
fi
if [[ -n $dec_fix ]] && [[ ! $dec_fix =~ ^-?[0-9]+x-?[0-9]+$ ]]; then
error "The decoration fix value must have form 'num'x'num'." \
"The numbers can be negative or zero."
echo >&2 "The decoration fix value must have form 'num'x'num'." \
"The numbers can be negative or zero." | tee -a "$MUTDROP_PATH"/log
exit 1
fi
# non-user-settable global vars
@ -359,7 +353,7 @@ decoration_settings() {
fi
fi
if [[ -z $dec_fix ]] && $auto_detect_wm; then
if [[ -z "$dec_fix" ]] && $auto_detect_wm; then
# settings for stacking/floating wms where can't get right position
# easily from xwininfo; take borders into account
if [[ $wm == Blackbox ]]; then
@ -373,10 +367,8 @@ decoration_settings() {
}
set_class() {
if [[ -z $class ]]; then
if [[ $program =~ ^emacsclient ]]; then
class=emacs
elif [[ $program =~ ^google-chrome ]]; then
if [[ -z "$class" ]]; then
if [[ $program =~ ^google-chrome ]]; then
class=google-chrome
elif [[ $program == st ]]; then
class=st-256color
@ -532,33 +524,110 @@ maybe_cancel_auto_show() {
fi
}
# * Dropdown Initialization
# TODO ideally this function wouldn't be necessary and some external program
# (something like xtoolwait) could be used to return the wid
create_win_return_wid() {
local blacklist program_command pid visible_wid wids wid program_wid
# blacklist all existing wids of program
# (for programs where one pid shares all wids)
blacklist=$(xdotool search --classname "$program")
# for programs where $! won't always work (e.g. one pid for all windows)
if [[ $program =~ ^(tilix|xfce4-terminal)$ ]]; then
pid=$(pgrep -x "$program")
elif [[ $program == urxvtc ]]; then
blacklist=$(xdotool search --classname urxvtd)
pid=$(pgrep -x urxvtd)
elif [[ $program == xiatec ]]; then
pid=$(pgrep -x xiate)
elif [[ $program == chromium ]]; then
# this may work fine
# pid=$(pgrep -xo chromium)
pid=$(pgrep -xa chromium | gawk '!/--type/ {print $1}')
elif [[ $program == chromium-browser ]]; then
pid=$(pgrep -xa chromium-browse | gawk '!/--type/ {print $1}')
elif [[ $program =~ ^google-chrome ]]; then
pid=$(pgrep -xa chrome | gawk '!/--type/ {print $1}')
elif [[ $program =~ ^emacsclient ]]; then
blacklist=$(xdotool search --classname emacs)
fi
# need to redirect stdout or function won't return
eval "$1 > /dev/null &"
if [[ -z $pid ]]; then
# for normal programs
# also for when one of the programs above hadn't already been started
pid=$!
fi
visible_wid=false
while : ; do
if [[ $program == gnome-terminal ]]; then
# only 1 pid; changes at some point after first run
# actual process name for me is gnome-terminal-
pid=$(pgrep gnome-terminal)
fi
if [[ $program == discord ]]; then
wids=$(xdotool search --classname discord)
blacklist=
elif [[ $program == qutebrowser ]]; then
# one pid, but can't use for getting wids with xdotool
wids=$(xdotool search --classname qutebrowser)
elif [[ $program =~ ^emacsclient ]]; then
wids=$(xdotool search --classname emacs)
else
wids=$(xdotool search --pid "$pid")
fi
if [[ -n "$wids" ]]; then
while read -r wid; do
if [[ ! $blacklist =~ (^|$'\n')"$wid"($|$'\n') ]] && \
[[ $(get_visibility "$wid") == IsViewable ]]; then
visible_wid=true
program_wid=$wid
fi
done <<< "$wids"
fi
if $visible_wid; then
break
fi
sleep 0.01
done
# workaround for urxvt tabbed plugin using -embed
if [[ $program =~ urxvt ]] && [[ -n $program_wid ]]; then
maybe_program_wid=$(xprop -id "$program_wid" | \
gawk -F '"' '/-embed/ {print $6}')
if [[ -n $maybe_program_wid ]]; then
program_wid=$maybe_program_wid
fi
fi
echo -n "$program_wid"
}
program_start() {
local program_command tmux_command wid
program_command=("$program")
if [[ $program == alacritty ]]; then
# prevent alacritty from resizing the terminal to 80x24
program_command+=(-d 0 0)
program_command="$program -d 0 0 $program_flags"
else
program_command="$program $program_flags"
fi
program_command+=("${program_flags[@]}")
if [[ -n $session_name ]]; then
if [[ -n "$session_name" ]]; then
session_name=$(printf "%q" "$session_name")
tmux_command="tmux attach-session -dt $session_name || \
tmux_command="'tmux attach-session -dt $session_name || \
tmuxifier load-session $session_name || \
tmuxinator start $session_name || \
tmux new-session -s $session_name"
tmux new-session -s $session_name'"
# note: st will work with or without the -e flag (like kitty)
# note: regular console works with or without quotes, but trinity's
# konsole only works without quotes
if [[ $program =~ ^(urxvt|alacritty|xiatec|st|lxterminal|qterminal|cool-retro-term|lilyterm|konsole$) ]]; then
program_command+=(-e bash -c "$tmux_command")
if [[ $program =~ ^(urxvt|alacritty|xiatec|st|lxterminal|qterminal|cool-retro-term|lilyterm|konsole$) ]]; then
program_command="$program_command -e bash -c $tmux_command"
elif [[ $program == kitty ]]; then
program_command+=(bash -c "$tmux_command")
program_command="$program_command bash -c $tmux_command"
else
program_command+=(-e "\"bash -c $tmux_command\"")
program_command="$program_command -e \"bash -c $tmux_command\""
fi
fi
wid=$(xtoolwait -wid "${program_command[@]}")
if [[ -n $name ]]; then
wid=$(create_win_return_wid "$program_command")
if [[ -n "$name" ]]; then
xdotool set_window --name "$name" "$wid"
fi
echo "$wid" > "$MUTDROP_PATH/$program$num"
@ -571,7 +640,7 @@ current_create() {
wid=$(xdotool getactivewindow)
echo "$wid" > "$MUTDROP_PATH"/current"$num"
get_class_name "$wid" > "$MUTDROP_PATH"/current"$num"_class
if [[ -n $name ]]; then
if [[ -n "$name" ]]; then
xdotool set_window --name "$name" "$wid"
fi
echo -n "$wid"
@ -767,19 +836,6 @@ 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
@ -796,8 +852,6 @@ 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,16 +4,13 @@
.SH NAME
Tdrop - make dropdown terminals and windows
.SH SYNOPSIS
tdrop [\fIOPTIONS\fR] [program name or cmd] [program options ...]
tdrop [\fIOPTIONS\fR] [program name or cmd]
.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, 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).
Tdrop expects the name of a program or 'current' (to use the current window) as the last argument to create a dropdown. 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).
.SH OPTIONS
.br
E.g.
@ -78,11 +75,7 @@ This option is a more complicated companion to -d that is also unlikely to be ne
Specify a command that will determine whether the current window is floating ($wid can be used in the command instead). Only used for the auto_hide command. This will be used to save whether the current window is floating or not. When restoring the window, if there is a float command and the window was previously floating, it will be floated. (default: none)
.TP
\fB-f\fR, \fB --program-flags\fR
NOTE: Using this flag is deprecated; it may be removed in the future. Instead, specify program flags after the program (e.g. "tdrop kitty --name foo").
Specify flags/options that the terminal or program should be called with. For example, to set the title of the terminal, something like 'tdrop -f "--title mytitle" <program>' can be used.
Caution: If there is a tmux session specified (with -s), the option to execute a program (usually -e for terminal programs) is implicitly added by tdrop! (default: none)
Specify flags/options that the terminal or program should be called with. For example, to set the title of the terminal, something like 'tdrop -f "--title mytitle" <program>' can be used. Caution: If there is a tmux session specified (with -s), the option to execute a program (usually -e for terminal programs) is implicitly added by tdrop! (default: none)
.TP
\fB-a\fR, \fB --auto-detect-wm\fR
If there are available settings for the detected window manager for the -l, -L, -d, and/or -i options, automatically set them. Takes no argument. Manually specified settings take precedence. This can be used both for dropdowns and the auto_(hide|show) commands. Takes no argument. (default: false)
@ -109,8 +102,6 @@ Used to clear a saved window id for the given program or 'current' instead of cr
.TP
\fB --no-cancel\fR
Specifies that manually re-showing an auto-hidden window with tdrop should not cancel an auto_show. Takes no argument. See the examples.
\fB --timeout\fR
Specifies the timeout in to wait for a window to appear when starting a program before giving up. This prevents a tdrop process from sticking around forever if a program fails to start. (default: 10)
.TP
\fB --help\fR
Print basic help information. Takes no argument.

Loading…
Cancel
Save