Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 46 lines (41 sloc) 1.319 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#!/bin/sh

exec &>/dev/null

windowname="$(xdotool search --onlyvisible . | while read -r; do
[ "$WINDOWID" == "$REPLY" ] && continue
xwininfo -id $REPLY | sed -n '/^xwininfo/s:.*"\(.\+\)".*:\1:p'
done | sort | uniq | dmenu -p "Select window by name: " -i -fn \
"-*-terminus-medium-r-*-*-12-*-*-*-*-*-*-*")"

windowid="$(xdotool search --onlyvisible "$windowname" | grep -v "$WINDOWID")"
idcount="$(wc -l <<EOF
$windowid
EOF
)"

if [ "$idcount" -eq 0 ]; then
    xdotool search --onlyvisible "$windowname" windowactivate
else
    [ "$idcount" -gt 1 ] && windowid="$(dmenu -p "Select window id: " \
-i -fn "-*-terminus-medium-r-*-*-12-*-*-*-*-*-*-*" <<EOF
$windowid
EOF
)"
    xdotool windowactivate "$windowid"
fi

# #!/bin/bash
#
# # titles as ids is problematic
# # anything unescaped will break this (':? etc)
#
# declare -A wins
#
# while read -r id; do
# name="$(xprop -id $id | sed -n 's/WM_NAME(STRING) = "\(.*\)"/\1/p')"
# [[ -z "${wins["$name"]}" ]] && wins+=(["$name"]="$id") || wins["$name"]+=" $id"
# done < <(xdotool search --onlyvisible .)
#
# sel="$(printf "%s\n" "${!wins[@]}" | dmenu -i)"
#
# ids=(${wins["$sel"]})
# (( ${#ids[@]} > 1 )) && id="$(printf -- "%s\n" "${ids[@]}" | dmenu -i)" || id="${ids["${sel}"]}"
#
# xdotool windowactivate "$id"
#
Something went wrong with that request. Please try again.