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 ## Tested With
### Terminals ### Terminals
- Termite - Termite
- URxvt - URxvt (including urxvtd)
- XTerm - XTerm
- Xfce4-terminal - Xfce4-terminal
- Gnome-terminal - Gnome-terminal
@ -78,7 +78,7 @@ mime ^video, has mpv, X, flag f = tdrop -a auto_hide && mpv -- "$@" && tdrop -a
- Terminology - Terminology
- Sakura - Sakura
- Roxterm - 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. 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 # use automatically set function if exists
elif [[ -n $(type map_pre 2> /dev/null) ]]; then elif [[ -n $(type map_pre 2> /dev/null) ]]; then
# needed when creating oneshot rules for programs where cmd differs from actual class name # 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" map_pre "Gnome-terminal"
elif [[ $1 == urxvtc ]]; then
map_pre "urxvt"
else else
map_pre "$1" map_pre "$1"
fi fi
@ -400,17 +402,31 @@ maybe_cancel_auto_show() {
# #
create_win_return_wid() { 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 # need to redirect stdout or function won't return
program_command="$1 > /dev/null &" program_command="$1 > /dev/null &"
eval "$program_command" # for programs where $! won't give the correct pid
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 visible_wid=false
while : ; do while : ; do
wids=$(xdotool search --pid "$pid") wids=$(xdotool search --pid "$pid")
if [[ -n "$wids" ]]; then if [[ -n "$wids" ]]; then
while read -r wid; do while read -r wid; do
if [[ $(get_visibility "$wid") == IsViewable ]]; then if [[ ! $blacklist =~ (^|$'\n')"$wid"($|$'\n') ]] && \
[[ $(get_visibility "$wid") == IsViewable ]]; then
visible_wid=true visible_wid=true
program_wid=$wid program_wid=$wid
fi fi

Loading…
Cancel
Save