Compare commits

..

108 Commits

Author SHA1 Message Date
KuxaBeast fa494e0e67
Fixed spelling 5 years ago
Jan Kužílek 5a85df2508 Replaced old wid-retrieving method with xtoolwait 5 years ago
Fox Kiester eb09fc22f7
Add shellcheck github action badge 5 years ago
Fox Kiester ffaf358bde
Fix shellcheck github action 5 years ago
Fox Kiester b4ddb1214b
Add github actions shellcheck workflow 5 years ago
Fox Kiester b7afed7b41
Give specific error when illegal opt is given 5 years ago
Fox Kiester 9c75b30212
Add timeout to wait for program window to appear
Also add error helper function and fix option validation.

Addresses #62. Prevents tdrop from spiking CPU forever if a program fails to
start.
5 years ago
Fox Kiester f4f0f34644
Add hide_all command
Fixes #60.
5 years ago
Fox Kiester 24d61bd266
Fix -a for emacsclient (set class as "emacs") 5 years ago
Fox Kiester 59c426dfc0
Remove unnecessary quotes 5 years ago
Fox Kiester 4926be8fcb
Allow specifying program flags after the program
This not working has caused a lot of confusion. Not only is -f not necessary,
but the implementation is worse than just allowing flags after the program.
Deprecate the -f flag. Stop evaling a string; build an array of program options
instead.

Addresses various issues: #6, #17, #52, etc.
5 years ago
Fox Kiester 2b1553090d
Fix shellcheck errors/warnings 5 years ago
Fox Kiester 5a44b827ad
Reindent 5 years ago
Fox Kiester c143104977
Suppress stderr when reading no_hide file 5 years ago
Fox Kiester 216070e29e
Improve performance
- Prefer builtins where possible
  - Use builtin math for percent_of_total
  - Use parameter expansion instead of awk where possible
  - Query specific property that want for xprop instead of using awk
- Avoid extra call to get_window_manager
- Use xrandr's --current flag (doesn't poll for hardware changes; ~0.01 second vs. 0.075 seconds on my comupter)
- Get current monitor name from bspc directly without parsing

Addresses #36.
5 years ago
Fox Kiester d74150f01f
Add support for Trinity's konsole (TDE)
Fixes #58.
5 years ago
Kamil Sołtysik 60435d240f
Pointer-based screen detection 5 years ago
Fox Kiester 183d983e4d
Explicitly use gawk and update dependency list
Fixes #49.
6 years ago
Fox Kiester 7eaa3b517d
Add support for qutebrowser
Fixes #56.
6 years ago
Fox Kiester 89d2e4ffce
Add workaround to support urxvt with tabbed plugin
Fixes #54.
6 years ago
Alexandr Priezzhev 198795c0d2
Fixes running Alacritty with the command shell argument 6 years ago
Fox Kiester 7d3192286a
Add initial support for emacsclient 6 years ago
Fox Kiester d91b1594b1
Add more broad urxvt name check for class inference
Addresses #47.
6 years ago
Fox Kiester 27894d40c3
Fix indentation/newline for --class in manpage 6 years ago
Fox Kiester fc2593f36e
Add initial discord support 6 years ago
Fox Kiester 5396d1bbdf
Mention that tdrop has a Void package
Re #43.
7 years ago
Fox Kiester c3978e3059
Update repository, contact, and version information 7 years ago
noctuid 6c7336d84a Prevent matching multiple monitors
Fixes #44.
7 years ago
noctuid 6adf44ef50 Improve explanation of geometry flags
Mention in basic flags section that geometry options can accept
percentages and negative numbers as arguments.
7 years ago
noctuid b7b529f80f Mention that --wm is needed if wmname has been used
Addresses #40.
7 years ago
noctuid 3f0867e565 Make own heading for -a explanation
Also swap flicker and -m headings.
7 years ago
noctuid 3278f76f9e Silence more irrelevant errors/output 7 years ago
noctuid 306bb984e4 Specify in readme that program arg should be last
Addresses #39.
7 years ago
noctuid ad8c192269 Clarify -f example in manpage
Addresses #39.
7 years ago
noctuid 8808dff04b Add -s support for lilyterm 7 years ago
noctuid 2ea52326bc Add -s support for LXTerminal
Also list related desktop environments for terminals.
7 years ago
noctuid 157ac0c2f1 Mention support for tinyterm/miniterm
Also rearrange terminals alphabetically.
7 years ago
noctuid 14a935ca24 Add support for -s for cool-retro-term 7 years ago
noctuid b1ba3b6129 Add -s support for qterminal 7 years ago
noctuid 498de5706e Fix -s for st and xst
Fixes #29.
7 years ago
noctuid 3aa34f7d21 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
7 years ago
noctuid baa61705f6 Update flicker section in readme: mention --name 7 years ago
noctuid 1a22a4158a Update basic flags section in readme
Reword and mention -m flag.
7 years ago
noctuid a6e3dbb7e8 Update/reword advantages section 7 years ago
noctuid ffef664678 Automatically use -d 0 0 with alacritty
Addresses #38.
7 years ago
noctuid 95d742acc0 Add -s support for kitty 7 years ago
noctuid 36995d1090 Fix geometry restoration for auto_show
Geometry restoration broke in 056edc6. Now width and height are also
explicitly restored.
7 years ago
noctuid 0facf21df7 Add tmuxifier support
Addresses #38.
7 years ago
noctuid bf97b17aaf Update demos 7 years ago
noctuid c72d00af39 Fix case when dropdown open on other desktop for i3
Addresses #21 and #35.
7 years ago
noctuid e24560402c Add argument descriptions to each flag line in man 7 years ago
noctuid 005e5bf547 Fix non-dropdown commands
These should not be checked as if they are programs.
7 years ago
noctuid b34232d299 Add --name flag
Closes #33.
7 years ago
noctuid 5373b5c31a Clarify the difference between classname and class 7 years ago
noctuid a80be242f9 Improve documentation of --class
Closes #33.
7 years ago
noctuid 7f521e5e78 README formatting fixes 7 years ago
noctuid 0928e7d885 Minor whitespace fix 7 years ago
noctuid bc46d9dcab Add check to ensure a valid program 7 years ago
noctuid 37224947e5 Terminix is now tilix 7 years ago
noctuid 099a4149d6 Update readme for new hooks and convert to org 7 years ago
noctuid f6fb40b74d Fix geometry reset for post-float WMs
Addresses #31.
7 years ago
noctuid 61c768bc68 Update manpage
- Add --wm and --class flags
- Rename to tdrop.1
7 years ago
noctuid bbb6ee5e5f Add support for xiate
Fixes #31.
7 years ago
noctuid e2b1495996 Update manpage
- fix hook/command options in manpage
- add new flags to manpage
- stop escaping unnecessarily escaping "-"
- Remove description from program help text (have only in manpage)
- change --subtract-when-same to --no-subtract-when-same (no longer
  takes an arg); remove unnecessary relate if/elseif/else
- add "map" to the pre/post float command long options
- silence ignorable shellcheck warnings
- "=" is no longer required with long options, so remove that warning
7 years ago
noctuid 428ee7c738 Fix map/unmap hooks
- Fix variable naming (remove _hook)
- Other minor stylistic changes (e.g. quotes)
8 years ago
noctuid d3346ec81e Update terminal list and add troubleshooting section 8 years ago
noctuid bc6a6eaf14 Add -s and -a support for alacritty
Closes #28
8 years ago
noctuid 850efe7212 Add -S and -i flags and update help text
The user now has complete control over everything -a alters.

All checks for the -a flags are now done in the helper functions.
"is_floating" is now always defined and will return 1 if the window is
not floating. Fix the float checks in mapping functions. Get rid of
separate "dec_fix_auto" variable.
8 years ago
noctuid 056edc6f56 Major updates
- Get rid of old method for -a; now mapping the window will always be
  combined with resetting its size and location; this may not be
  necessary, but in those cases, it won't cause any harm; this means
  that there is no reason to differentiate between window managers that
  move or resize windows as this possibility will always be taken into
  account
- Don't record last monitor and check to see whether a geometry change
  is necessary; just always fix the geometry (same reasoning as previous
  point; there is no significant overhead)
- Finish transition to new "hooks" (pre/post create/float/map/unmap)
- Make the naming of the hook variables consistent (pre/post first)
- Make wid and class global variables
- Add --wm and --class options (wm option may only be useful in limited
  circumstance since most settings are now very specific to their wm;
  this may change in the future or this setting may be useful in the
  possible case that a similar fork of a wm has a different name)
- Switch to org style headings

Still needs to be done:
- further testing
- documentation (help, readme, manpage)
8 years ago
noctuid 0dc7c2825b Rename some functions 8 years ago
noctuid ac0f811cab Fix tmux handling for urxvtc
Fixes #30.
8 years ago
noctuid 68f833a25a Add st to the tested terminal list.
Addresses #29.
8 years ago
noctuid e6e52dcf4d Silence complaints about wid file not existing
Addresses #29.
8 years ago
noctuid 914c535cda Add class name translation for st (for bspwm)
Addresses #29.
8 years ago
noctuid cf7b1a3a22 Update manpage to mention multi-user support
Also make some minor quoting changes and silence shellcheck errors.
8 years ago
noctuid ada5ec6fb4 Merge branch 'TuXicc-master' 8 years ago
Kai Fartaczek 2564d7ff09 added multi-user support 8 years ago
noctuid e9e222f6fa Ignore disabled monitors for -m
Don't check monitors without dimensions in xrandr's output.
Addresses #26.
8 years ago
noctuid 45e9d72711 Fix support for gnome-terminal
Fixes #25.
8 years ago
noctuid 4661ea84af Drop support for prior versions of bspwm 8 years ago
noctuid c0f0c7fecc Reset position of bspwm dropdowns upon mapping
Newer versions of bspwm (0.9.1) occasionally the move a dropdown to the
center of the screen when remapping it. Fixes #23.
8 years ago
noctuid 2937b69f11 Move dropdown when it is open on another desktop
For most WMs (awesome is an exception), windows that are open on another
desktop are reported as unmapped which causes nothing to happen if a
tdrop command is run (unmapping/mapping don't work in this case). Moving
a dropdown to the current desktop is possible with xdotool though
(basically the same as wmctrl's -R). This is a temporary solution that
may be need to be refined in the future. A potential issue is whether
pre/post map hooks should be run in this case (e.g. rules should not be
added again for bspwm). This could be fixed later by actually unmapping
the window or by adding more specific hooks. Addresses #21.
8 years ago
noctuid 9609e25621 Fix pid handling in create_win_return_wid
- Simplify logic
- Properly handle both the case where a "special" program needs to be
  started and where it has already been started (did not actually work
  before because the first pgrep somehow stopped the second from working
  correctly)
- Add support for "chromium-browser"

Closes #20.
9 years ago
noctuid f028683a38 Add workaround for chrome
Classname may differ from command name (e.g. google-chrome vs.
google-chrome-stable).
9 years ago
noctuid 77992cf141 Add support for google chrome
Also fix support for chromium when it hasn't been previously started.
Addresses #20.
9 years ago
noctuid 9bc0deade7 Fix support for xfce4-terminal
Addresses #20.
9 years ago
noctuid 2aed1021c5 Add support for chromium
Fixes #20.
9 years ago
noctuid b66e7e661b Allow -x and -y to take a percentage or negative
With this, '-m' is no longer required for negative values to be used
with any of the geometry options (-w/-y/-x/-y). Also, tdrop no longer
relies on xdotool's ability to take percentages directly (for
windowsize). Fixes #19.
9 years ago
noctuid 4c53ab2892 Suppress more ignorable errors
The map_post commands that actually combine movement with mapping will
cause an error when first creating a dropdown since in this case the
window is already mapped. Addresses #17.
9 years ago
noctuid 70c78039cf Add a --map-hook flag
Addresses #17.
9 years ago
noctuid 13a658fde0 Add a --create-hook option that won't override -a
Addresses #17.
9 years ago
noctuid e1c2622301 Update to support bspwm 0.9.1
- Fix floating rules
- Fix is_floating (for auto_hide and auto_show)
- Fix for -m option
9 years ago
noctuid 23e751d5a8 Merge branch 'ShadowKyogre-added-compiz-check' 9 years ago
ShadowKyogre bb1f0b19e2 Add additional compiz check
Compiz Reloaded / Compiz 0.8.x reports itself with a lowercase compiz.
9 years ago
noctuid 9c8e3d3d76 Merge branch 'schoettl-patch/bugfix' 9 years ago
noctuid 39b71e4638 Merge branch 'patch/bugfix' of https://github.com/schoettl/tdrop into schoettl-patch/bugfix 9 years ago
Jakob Schöttl cacd3c50d1 Bugfix in help text: default values 9 years ago
noctuid 661eaa76ba Update shebang 9 years ago
noctuid f883f81e5a Don't output errors of non-existent files 9 years ago
noctuid ddafeda140 Remove pkgbuild from repository 9 years ago
noctuid 38fdcce05e Update contact information 9 years ago
noctuid 8cad7fb8eb Don't output xprop error messages
Ignore errors when checking for visibility. Addresses #14.
9 years ago
noctuid 9b4f0fe713 Add support for compiz
Addresses #14.
9 years ago
noctuid a4af855882 Mention improved long option parsing in README 9 years ago
noctuid fb60bd6642 Add support for long options without =
Closes #12
9 years ago
noctuid 40917af009 Send error messages to STDERR 9 years ago
noctuid f4f58b66e9 Escape tmux session name
This will, for example, allow session names to have whitespace (not that
that's a good idea, but if the session name is quoted like -s "a b",
then the expected behavior is to get a session named "a b" not for tdrop
to fail).
9 years ago
noctuid 702f047b6b Error in the case of multiple positional arguments 9 years ago

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

@ -1,4 +1,4 @@
Copyright (c) 2015, Lit Wakefield
Copyright (c) 2015, Fox Kiester
All rights reserved.
Redistribution and use in source and binary forms, with or without

@ -6,7 +6,7 @@ LICENSEDIR = $(PREFIX)/share/licenses
install:
# 755 is default
install -D -m 755 tdrop "$(DESTDIR)$(BINDIR)"/tdrop
install -D -m 644 tdrop.groff "$(DESTDIR)$(MANDIR)"/man1/tdrop.1
install -D -m 644 tdrop.1 "$(DESTDIR)$(MANDIR)"/man1/tdrop.1
install -D -m 644 LICENSE "$(DESTDIR)$(LICENSEDIR)"/tdrop/LICENSE
uninstall:

@ -1,29 +0,0 @@
# Maintainer: Lit Wakefield <noct[at]openmailbox[dot]org>
_pkgname=tdrop
pkgname=tdrop-git
pkgver=
pkgrel=1
pkgdesc="A WM-Independent dropdown window and terminal creator"
arch=('any')
url="https://github.com/noctuid/tdrop"
license=('Simplified BSD')
depends=('bash' 'xdotool' 'xorg-xwininfo' 'xorg-xprop')
optdepends=('tmux: session starting support'
'tmuxinator: session starting support'
'sxhkd: for a tdrop keybinding'
'xorg-xrandr: multiple monitor resizing support')
makedepends=('git')
provides=("${_pkgname}")
md5sums=('SKIP')
source=("git://github.com/noctuid/${_pkgname}.git")
pkgver() {
cd "$srcdir/$_pkgname"
git describe --long | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}
package() {
cd "$srcdir/$_pkgname"
make PREFIX=/usr DESTDIR="$pkgdir" install
}

@ -1,130 +0,0 @@
## Demos
A basic demo using tdrop to create a dropdown/scratchpad on the fly with a hotkey. I set the height to be less than max with tdrop to make it more obvious which is the dropdown at which time. First apvlv is turned into a dropdown. Then it is cleared and zathura is turned into a dropdown. One can also have multiple hotkeys to create multiple dropdowns on the fly at a time.
![Alt text](http://noctuid.github.io/tdrop/assets/on_the_fly.gif "On the fly creation")
A demo showing tdrop's ability to auto-hide windows when opening things from them. First an image is opened in sxiv from ranger in the dropdown. When sxiv is closed, the dropdown automatically re-appears. The image is opened once again, but this time the dropdown is manually toggled before closing sxiv. This cancels the "re-show".
![Alt text](http://noctuid.github.io/tdrop/assets/auto_hide.gif "Auto Hiding")
## Advantages Over Other Dropdown Terminals
- Can be used with any terminal or other program of your choice
- Allows turning any window into a dropdown on the fly
- Allows for control of sizing and initial placement so that panels aren't hidden
- Supports tiled and floating dropdowns
- Attempts to deal with floating windows on a case by case basis (ability to have a floating dropdown without needing a rule to float all windows of that type)
- Allows for multiple dropdowns of the same type (works by window id)
- Allows for auto-hiding a dropdown when opening programs from it
- Can automatically start programs and tmux or tmuxinator sessions
- Supports automatic resizing based on the current monitor
## Requirements
- xprop
- xwininfo
- xdotool
- tmux (optional)
- tmuxinator (optional)
## Installation Instructions and Usage
Tdrop is in the AUR as `tdrop-git`. 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:
```
alt + s
tdrop -a -w 1362 -y 14 -s dropdown termite
```
### Basic Flags
`-s` should only be used for supported terminals and if the user wants to start a tmux or tmuxinator session. `-a` should be used to set up WM specific rules (which are required for the --width, --height, --xoff, and --yoff flags to work properly; see below for supported WMs). Refer to `tdrop --help` and the manpage for more complete instructions.
Tdrop has basic checks to print errors for malformed commands (for example to require the 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.
**Changes**:
Old users please note that `-W|--normal-window`, `-z|--sleep-terminal`, and `-Z|--sleep-window` are no longer necessary and have been removed.
### Flicker
For some window managers that require a window to be repositioned after re-mapping it, some flicker may be noticeable. With a recent change, this flicker is pretty much gone for some window managers (e.g. in the Gnome Shell and Cinnamon DEs) and slightly better than before in other
s. 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 floated or one-time rules to only float the next instance of a class. For example, since bspwm has oneshot rules and won't alter the size/position of a window, this flicker is not a problem.
However, the consistent way to eliminate visual flickering due to moving/resizing for any 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 .compton.conf accordingly.
### Monitor Awareness
Using the `-m`/`--monitor-aware` flag has two purposes. For those who use a single monitor, it allows specifying a negative number to `-w` or `-h`. For example, `-w -4` corresponds to a width 4 pixels less than 100% of the screen width. This 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.
For those who use multiple monitors, using `-m` will additionally alter the width and height options to correspond to the current monitor. This means that `-w 100%` will cause the dropdown to occupy the full width of the current monitor instead of spanning all monitors. Also, the `-m` option will automatically resize the dropdown when opening it on a different monitor if the width or height 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.
### 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:
```
hide_on_open() {
tdrop -a auto_hide && "$@" && tdrop -a auto_show
}
alias gc='hide_on_open git commit'
```
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`:
```
mime ^video, has mpv, X, flag f = tdrop -a auto_hide && mpv -- "$@" && tdrop -a auto_show
```
## Tested With
### Terminals
- Termite
- URxvt (including urxvtd)
- XTerm
- Xfce4-terminal
- Gnome-terminal
- Konsole
- Terminology
- Sakura
- Roxterm
- Terminix (-s will not work if the terminix process is already running)
If your terminal doesn't work with tdrop, feel free to make an issue.
### 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) and how it deals with window managers that resize or move a window after unmapping then mapping it. 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 <settings> term` 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 (use '-a'):
- herbstluftwm
#### Floating/Stacking
For floating window managers, tdrop should also generally "just work", but you will need to add the '-a' option. Many floating window managers will either center or resize a window when mapping then unmapping it. Tdrop provides for a `--post-commmand` to deal with this. '-a' will automatically determine the proper post command to use for your window manager if one exists. The '-a' option will also set things up so that window geometry/position will be properly restored on an `auto_show`.
That said, these are the floating window managers that currently have '-a' settings:
- mutter (gnome shell)
- muffin (cinnamon)
- xfwm4 (xfce)
- metacity (gnome 2)
- marco (mate)
- kwin (kde)
- openbox (lxde)
- pekwm
- fluxbox
- blackbox
- fvwm
- sawfish
- goomwwm
Usually, it is a simple matter to add new ones to this list. 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
- i3
- awesome
Awesome support may be buggy; if you encounter problems, please report them. Unmapping behaviour is different on awesome for some reason, so tdrop will act different when the dropdown is open on another workspace/tag (first call will unmap it and the second will map it on the current tag).
## 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 and resizing to a percentage isn't supported (would have to convert percentages to pixels).
## Similar:
- [drawer](https://github.com/lharding/lsh-bin/blob/master/drawer)

@ -0,0 +1,5 @@
* 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.
Just don't forget to install xtoolwait, because I basically replaced hundred lines of code with just one call to this utility.

1084
tdrop

File diff suppressed because it is too large Load Diff

@ -0,0 +1,201 @@
.\" Man page for tdrop.
.\" Please make an issue on the online repository if you find errors or typos.
.TH TDROP 1 "11 February 2015" "tdrop 0.2" "tdrop man page"
.SH NAME
Tdrop - make dropdown terminals and windows
.SH SYNOPSIS
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, 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.
.br
$ tdrop -y 15 termite
.br
$ tdrop --y-offset=15 termite
.br
$ tdrop --y-offset 15 termite
.TP
Note that all hook and command related options can make use of any tdrop variables (such as $width, $height, $xoff, $yoff, $class, $wid, etc.). 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).
.TP
\fB-w WIDTH\fR, \fB --width=WIDTH\fR
Specify a width for a created window as a number or percentage. A negative number is allowed (e.g. '-w -4') in which case the width will be that many pixels less than 100% of the screen size (or monitor size if '-m' is being used). This fixes the problem where 100% width may actually go over the screen due to window borders/decoration. The other other geometry options also accept negative values ('-h', '-x', and '-y'). (default: 100%)
.TP
\fB-h HEIGHT\fR, \fB --height=HEIGHT\fR
Specify a height for a created window as a number or percentage. (default: 45%)
.TP
\fB-x OFFSET\fR, \fB --x-offset=OFFSET\fR
Specify the x position for a created window as a number or percentage. (default: 0)
.TP
\fB-y OFFSET\fR, \fB --y-offset=OFFSET\fR
Specify the y position for a created window as a number or percentage. (default: 1, see BUGS)
.TP
\fB-s NAME\fR, \fB --session=NAME\fR
Specify a tmuxinator, tmuxifier, or tmux session name to start. An existing tmux session has highest precedence and will be connected to with '-d', detaching other attached clients. If a there is no tmuxinator/tmuxifier/etc. session of the given name, a normal tmux session with the name will be created. If this option is not given, tmux will not be used. Note that this option requires that the program be a supported terminal. (default: none)
.TP
\fB-n NUMBER\fR, \fB --number=NUMBER\fR
Specify a number (or any extra text) to differentiate between dropdowns of the same program (this is only needed when using multiple dropdowns of the same program). This flag can also be used for creating multiple different dropdowns on the fly ('current'). Note that it is not necessary to use this to deal with multi-user systems as tdrop stores dropdown information separately for each user. (default: none)
.TP
\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 --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)
.TP
\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-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
\fB-S\fR, \fB --no-subtract-when-same\fR
This option is a more complicated companion to -d that is also unlikely to be needed. This is used to determine how to calculate the X and Y position of a window using xwininfo when 'auto_hide' is used (if the absolute and relative X or Y values are reported as the same, this option determines the behavior). If you are sure you have the decoration size correct, but windows are still being restored in an incorrect position with 'auto_show', you may want to try using this. Takes no argument. (default: false)
.TP
\fB-i\fR, \fB --is-floating\fR
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)
.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)
.TP
\fB-m\fR, \fB --monitor-aware\fR
This option only applies for dropdowns (not auto-hiding and auto-showing). Specify that geometry values should be relative to the current monitor. For example, if the width is a percentage or negative value, the pixel width will be calculated as a percentage of the current monitor's width (instead of the combined width of all monitors). If the monitor changes, this option will cause a dropdown to be resized to fit the given percentages. Note that this option assumes xrandr is being used and requires xrandr to work. (default: false)
.TP
\fB-t\fR, \fB --pointer-monitor-detection\fR
Use mouse pointer location for detecting which monitor is the current one so terminal will be displayed on it. Without this option, the monitor with currently active window is considered the current one. This option is only effective if -m / --monitor-aware option is enabled.
.TP
\fB --wm=NAME\fR
Specify the window manager name (which determines the default settings when -a is specified). This may be useful if you've change the name of your window manager using wmname as this will prevent tdrop from correctly detecting the real window manager name. This could also potentially be useful if the all the default -a settings for another window manager work with the current one (e.g. if using a similar but differently named fork of some window manager). (default: automatically detected)
.TP
\fB --class=NAME\fR
Providing this option lets tdrop know what the class (or classname) of the window is (it does not actually set the class for a window). This is used for window managers like bspwm that use the class for floating rules. For some commonly used programs, tdrop will already use the correct class. This option is useful when the program name and class are not the same and there is not already a default mapping between the two. (default: the program name or a known substitution)
Both the class and classname of a window can be obtained using xprop (see WM_CLASS). As for the difference, generally the class starts with an uppercase letter and the classname starts with a lowercase letter. The xprop output may only list one for some programs (e.g. urxvt only has "urxvt"). Currently this option is only useful for bspwm, and it does not matter whether the class or classname (which bspwm calls an instance name) is provided, so the user does not really need to worry about the distinction.
.TP
\fB --name=NAME\fR
This option only applies for dropdowns (not auto-hiding and auto-showing). Set a new name for the dropdown window (see _NET_WM_NAME and WM_NAME in xprop output). This option may be useful if you want to add specific rules just for dropdowns with a program like compton by giving them a common title. (default: none)
.TP
\fB --clear\fR
Used to clear a saved window id for the given program or 'current' instead of creating a dropdown. Takes no argument.
.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.
.SH EXAMPLES
.SS Making Dropdowns
Use a key binding program such as sxhkd to bind keys to these commands.
The simplest example to make a dropdown for an xterm:
.br
$ tdrop xterm
When using a tiling window manager like bspwm, dropdowns like guake will by default be tiled instead of floated. One can create a rule to float every instance of guake or another dropdown. However, one may not want to float every instance of a terminal used with tdrop. Tdrop allows the user to run their own commands at various points during execution, for example before mapping the window:
.br
$ tdrop -p "bspc rule -a xterm -o floating=on" xterm
Tdrop also provides tested settings for certain window managers. One can use the '-a' flag if settings exist for the current window manager. For example, if bspwm is the window manager, the following command is the same as the above command and will work for whatever terminal/program is specified and will also work with 'tdrop auto_show'. For a list of window managers with tested settings see the readme or the script itself.
.br
$ tdrop -a xterm
Tdrop supports controlling the initial size and placement of a terminal. The border of a window may need to be taken into an account. For example, I use a border size of 2, so I use 4 less than my screen size. I also use a y-offset of 14 so that the dropdown doesn't hide my panel:
.br
$ tdrop -a -w 1362 -y 14 xterm
Tdrop can also create a tmux session if it does not exist:
.br
$ tdrop -a -w 1362 -y 14 -s dropdown xterm
Tdrop allows for having multiple dropdowns of the same type:
.br
$ tdrop xterm
.br
$ tdrop -n 1 xterm
.br
$ tdrop -n 2 xterm
.br
...
Tdrop works with normal windows (with some potential visual annoyance, see BUGS):
.br
$ tdrop zathura
.br
# the current window
.br
$ tdrop current
Once a window is turned into a dropdown, the key bound to 'tdrop ... current' will continue to toggle that window until it is closed. Then the key can be used to create a new dropdown. '-n' can also be used to have multiple 'current' keys. If an active window is accidentally turned into a dropdown, it can be cleared:
.br
$ tdrop --clear current
.br
# clear a specific number
.br
$ tdrop -n 1 --clear current
.SS Auto-hiding/showing
These example will work even for non-dropdown terminals.
Tdrop provides the functionality to get programs/terminals out of the way when opening other programs. For example, when opening an image viewer from a normal floating dropdown, the dropdown will be over the image viewer. This requires an extra hotkey press to hide the dropdown. If one wants to return to the dropdown after looking at images, the hotkey must be once again invoked. Tdrop allows for this process to be automated.
For example, this could be added to a shell's config/startup file:
.br
hide_on_open() { tdrop -a auto_hide; "$@" && tdrop -a auto_show }
To use it in an alias when writing a commit message in an graphical $EDITOR started from a terminal:
.br
alias gc='hide_on_open git commit'
This will hide the terminal window when opening the commit editor and then reshow the terminal once the editor is closed. It should also maintain the window's position and size when showing it. If the window moves down and to the right every time it is auto-hidden and then shown again, the user may need to specify a -d value. Alternatively, if one already exists for the user's window manager, -a can be used to automatically set it. The -l and -L options are also used with auto_show and can be set automatically with -a if default settings exist for the current window manager.
Note that for tiling window managers that support 'tdrop -a auto_show', reshowing a window will always float the window (even if it was orignally tiled) if -i is not specified. To prevent this, also use 'tdrop -a auto_hide' if your window manager is supported. Otherwise, -i must be manually specified with auto_hide.
This functionality might lead to some unwanted "re-shows" of dropdown. Consider a situation in which one opens an image viewer from a dropdown and leaves it open for a while, resuming normal use of the dropdown. When the image viewer is closed, the dropdown appears, unwanted. Tdrop is smart about this and won't "re-show" a dropdown if it has been manually toggled since an auto-hide. If you don't want this check to happen, use '--no-cancel' in your dropdown key binding.
Auto-hiding functionality is particularly nice to use with a file opener like rifle:
.br
mime ^image, has sxiv, X, flag f = tdrop auto_hide ; sxiv -a -- "$@" && tdrop -a auto_show
.SH BUGS
If -y is set to 0, a window may be subsequently moved to the middle when showing/mapping it with xdotool. This may have to do with the window border.
.SH AUTHOR
Fox Kiester <noct at posteo\&.net>
.br
Source: https://github.com/noctuid/tdrop
.SH SEE ALSO
xdotool(1), sxhkd(1), xprop(1), xwininfo(1), tmux(1)

@ -1,145 +0,0 @@
.\" Manpage for tdrop.
.\" Contact <noct at openmailbox dot org> to correct errors or typos.
.TH TDROP 1 "11 February 2015" "tdrop 0.1" "tdrop man page"
.SH NAME
Tdrop \- make dropdown terminals and windows
.SH SYNOPSIS
tdrop [\fIOPTIONS\fR] [program name or cmd]
.SH DESCRIPTION
Tdrop is used for hiding/unhiding programs to acheive quake-dropdown-like-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, e.g. to leave panels visible or deal with window borders. When used with a terminal, it provides the option to specify the name of a tmuxinator or tmux session to automatically start. It uses window ids as opposed to class names, so it can be used with multiple windows of the same program.
It also has the ability to auto-hide and auto-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., and then re-show 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 turn the current window into a dropdown) as the last argument. Alternatively, it can take one of auto_show, auto_hide, or toggle_auto_hide. Neither is particularly useful called directly from the command line; the former should be bound to a key, and the latter should be used in shell functions/aliases or for a file opener (e.g. in the rifle.conf).
.SH OPTIONS
Note: longopts that take an arg require using =.
.br
E.g.
.br
$ tdrop --y-offset=15 termite
.TP
\fB\-h\fR, \fB \-\-height\fR
Specify a height for a created window as a number or percentage. (default: 45%)
.TP
\fB\-w\fR, \fB \-\-width\fR
Specify a width for a created window as a number or percentage. (default: 100%)
.TP
\fB\-x\fR, \fB \-\-x-offset\fR
Specify the x position for a created window as a number or percentage. (default: 0)
.TP
\fB\-y\fR, \fB \-\-y-offset\fR
Specify the y position for a created window as a number or percentage. (default: 1, see BUGS)
.TP
\fB\-s\fR, \fB \-\-session\fR
Specify a tmuxinator or tmux session name to start. An existing tmux session has highest precedence and will be connected to with '-d', detaching other attached clients. If a there is no tmuxinator session of the given name, a normal tmux session with the name will be created. If this option is not given, tmux will not be used. Note that this option requires that the program be a supported terminal. (default: none)
.TP
\fB\-n\fR, \fB \-\-number\fR
Specify a number to add when saving dropdown information. Only needed if multiple dropdowns of the same program are wanted. Can also be used for creating multiple different dropdowns on the fly. (default: none)
.TP
\fB\-p\fR, \fB \-\-pre-command\fR
Specify a command to execute before showing/mapping a dropdown. This may be useful when setting a rule to float all windows of a given type is undesirable. If 'bspwm' is given, the command will be a oneshot bspwm rule to float the specified program and will also work with 'current' and 'auto_show'. (default: none)
.TP
\fB\-P\fR, \fB \-\-post-command\fR
Specify a command to execute after showing/mapping a dropdown. This may be useful in the case where a window manager does not support floating rules or floating altogether. It can be used, for example, to fake a key combo to float the current window. (default: none)
.TP
\fB\-M\fR, \fB \-\-post-unmap\fR
Specify a command to execute after unmapping a dropdown. This can be used with window managers that don't support floating in conjunction with '-p' or '-P' to, for example, change the layout to fullscreen when mapping a dropdown and then revert it when umapping it. (default: none)
.TP
\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)
.TP
\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)
.TP
\fB\-f\fR, \fB \-\-program-flags\fR
Specify flags/options that the terminal or program should be called with. For example, to set the title of the terminal, something like '-f "--title mytitle"' can be used. 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! (default: none)
.TP
\fB\-a\fR, \fB \-\-auto-detect-wm\fR
If there are available settings for the detected window manager for the -p, -P, -M, and/or -d options, automatically set them; takes no argument. User set settings will still override these. This can be used with 'tdrop <terminal>', 'tdrop auto_hide', and 'tdrop auto_show'. For 'auto_hide', if the window manager is supported, it will check if the current window is tiled so that it is not changed to floating when auto-showing. (default: false)
.TP
\fB\-m\fR, \fB \-\-monitor-aware\fR
This option only applies for dropdowns (not auto-hiding and auto-showing). Specify that width and height percentages should be relative to the current monitor. If the monitor changes, this option will cause a dropdown to be resized to fit the given percentages. A negative argument is also allowed for '-w' and '-y' with this option (e.g. '-m -w -4') in which case the determined value will be that many pixels less than 100% of the screen size. This fixes the problem where 100% width may actually go over the screen due to window borders/decoration. Note that this option assumes xrandr is being used and requires xrandr to work. (default: false)
.TP
\fB\-c\fR, \fB \-\-clear\fR
Used to clear a saved window id for the given program or 'current' instead of creating a dropdown; takes no argument.
.TP
\fB\-C\fR, \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 examples.
.TP
\fB\-H\fR, \fB \-\-help\fR
Print help that is less awesome than this manpage; takes no argument.
.SH EXAMPLES
.SS Making Dropdowns
Use a key binding program such as sxhkd to bind keys to these commands.
The simplest example to make a dropdown for an xterm:
.br
$ tdrop xterm
When using a tiling window manager like bspwm, dropdowns like guake will by default be tiled instead of floated. One can create a rule to float every instance of guake or another dropdown. However, one may not want to float every instance of a terminal used with tdrop. Tdrop allows for having a "pre command" that will run before showing a dropdown:
.br
$ tdrop -p "bspc rule -a xterm -o floating=on" xterm
Tdrop also provides tested settings for certain window managers. One can use the '-a' flag if settings exist for the current window manager. For example, if bspwm is the window manager, the following command is the same as the above command and will work for whatever terminal/program is specified and will also work with 'tdrop auto_show'. For a list of window managers with tested settings see the readme or the script itself.
.br
$ tdrop -a xterm
Tdrop supports controlling the initial size and placement of a terminal. The border of a window may need to be taken into an account. For example, I use a border size of 2, so I use 4 less than my screen size. I also use a y-offset of 14 so that the dropdown doesn't hide my panel:
.br
$ tdrop -a -w 1362 -y 14 xterm
Tdrop can also create a tmux or tmuxinator session if it does not exist:
.br
$ tdrop -a -w 1362 -y 14 -s dropdown xterm
Tdrop allows for having multiple dropdowns of the same type:
.br
$ tdrop xterm
.br
$ tdrop -n 1 xterm
.br
$ tdrop -n 2 xterm
.br
...
Tdrop works with normal windows (with some potential visual annoyance, see BUGS):
.br
$ tdrop zathura
Tdrop can also turn the current window into a dropdown. '-O' is useful in this case to execute a command only once when turning the active window into a dropdown.
.br
$ tdrop -a -O "bspc window -t floating=on && xdotool getactivewindow windowmove 0 14 windowsize 1362 45%" current
Once a window is turned into a dropdown, the key bound to 'tdrop ... current' will continue to toggle that window until it is closed. Then the key can be used to create a new dropdown. '-n' can also be used to have multiple 'current' keys. If an active window is accidentally turned into a dropdown, it can be cleared:
.br
$ tdrop --clear current
.SS Auto-hiding/showing
These example will work even for non-dropdown terminals.
Tdrop provides the functionality to get programs/terminals out of the way when opening other programs. For example, when opening an image viewer from a normal floating dropdown, the dropdown will be over the image viewer. This requires an extra hotkey press to hide the dropdown. If one wants to return to the dropdown after looking at images, the hotkey must be once again invoked. Tdrop allows for this process to be automated.
For example, this functionality can be used in a function:
.br
hide_on_open() { tdrop -a auto_hide; "$@" && tdrop -a auto_show }
To use it in an alias when writing a commit message in an graphical $EDITOR started from a terminal:
.br
alias gc='hide_on_open git commit'
This will hide the terminal window when opening the editor and then show it once the editor is closed. It should also maintain the window's position and size when showing it. If the window moves down and to the right every time it is auto-hidden and then shown again, the user may need to specify a '-d' value. Alternatively, if one already exists for the user's window manager, '-a' can be used to automatically set it. The '-p' and '-P' options are also used with auto_show and can be set automatically with '-a' if tested settings exist for the current window manager.
Note that for tiled window managers that support 'tdrop -a auto_show' there will be problems when auto-hiding from a tiled window. When re-showing the window, it will be floating (since geometry is by default saved and restored). To keep it tiled, also use 'tdrop -a auto_hide' if your window manager is supported. This will check if a window is floating or tiled and keep it that way.
This functionality might lead to some unwanted "re-shows" of dropdown. Consider a situation in which one opens an image viewer from a dropdown and leaves it open for a while, resuming normal use of the dropdown. When the image viewer is closed, the dropdown appears, unwanted. Tdrop is smart about this and won't "re-show" a dropdown if it has been manually toggled since an auto-hide. If you don't want this check to happen, use '--no-cancel' in your dropdown key binding.
Auto-hiding functionality is particularly nice to use with a file opener like rifle:
.br
mime ^image, has sxiv, X, flag f = tdrop auto_hide ; sxiv -a -- "$@" && tdrop -a auto_show
.SH SEE ALSO
xdotool(1), sxhkd(1), xprop(1), xwininfo(1), tmux(1)
.SH BUGS
If -y is set to 0, a window may be subsequently moved to the middle when showing/mapping it with xdotool. This may have to do with the window border.
.SH AUTHOR
Lit Wakefield <nocturnalartifice at gmail dot com>
.br
Source: https://github.com/noct/tdrop
Loading…
Cancel
Save