Add support for urxvtd and terminix

Programs with a shared pid for all windows need to be treated
differently.
long-opts
noctuid 9 years ago
parent e07d993262
commit c7b8ab343f

@ -70,7 +70,7 @@ mime ^video, has mpv, X, flag f = tdrop -a auto_hide && mpv -- "$@" && tdrop -a
## Tested With
### Terminals
- Termite
- URxvt
- URxvt (including urxvtd)
- XTerm
- Xfce4-terminal
- Gnome-terminal
@ -78,7 +78,7 @@ mime ^video, has mpv, X, flag f = tdrop -a auto_hide && mpv -- "$@" && tdrop -a
- Terminology
- Sakura
- Roxterm
- Terminix
- 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.

26
tdrop

@ -359,8 +359,10 @@ map_pre_command() {
# use automatically set function if exists
elif [[ -n $(type map_pre 2> /dev/null) ]]; then
# needed when creating oneshot rules for programs where cmd differs from actual class name
if [[ $1 == "gnome-terminal" ]]; then
if [[ $1 == gnome-terminal ]]; then
map_pre "Gnome-terminal"
elif [[ $1 == urxvtc ]]; then
map_pre "urxvt"
else
map_pre "$1"
fi
@ -400,17 +402,31 @@ maybe_cancel_auto_show() {
#
create_win_return_wid() {
local program_command pid visible_wid wids program_wid
local blacklist program_command pid visible_wid wids program_wid
# blacklist all existing wids of program
# (for programs where one pid shares all wids)
blacklist=$(xdotool search --classname "$program")
# need to redirect stdout or function won't return
program_command="$1 > /dev/null &"
eval "$program_command"
pid=$!
# for programs where $! won't give the correct pid
if [[ $program == terminix ]] && pgrep terminix; then
pid=$(pgrep terminix)
eval "$program_command"
elif [[ $program == urxvtc ]]; then
blacklist=$(xdotool search --classname urxvtd)
pid=$(pgrep urxvtd)
eval "$program_command"
else
eval "$program_command"
pid=$!
fi
visible_wid=false
while : ; do
wids=$(xdotool search --pid "$pid")
if [[ -n "$wids" ]]; then
while read -r wid; do
if [[ $(get_visibility "$wid") == IsViewable ]]; then
if [[ ! $blacklist =~ (^|$'\n')"$wid"($|$'\n') ]] && \
[[ $(get_visibility "$wid") == IsViewable ]]; then
visible_wid=true
program_wid=$wid
fi

Loading…
Cancel
Save