diff --git a/README.md b/README.md index 87883ba..63e8555 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/tdrop b/tdrop index 9dda0fc..3146e78 100755 --- a/tdrop +++ b/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