diff options
author | Gabor Adam Toth <tg@tgbit.net> | 2012-10-02 14:10:57 +0200 |
---|---|---|
committer | Thorsten Wißmann <re06huxa@stud.informatik.uni-erlangen.de> | 2012-10-02 15:17:24 +0200 |
commit | 9562cf984a7b0e661ebd0bf9bc5098f9e504671b (patch) | |
tree | 010b22798766e426143a5403127fefea6d59c518 /scripts | |
parent | 3dafabe6c1a79dd9149ad90699b5e5edee923fe9 (diff) |
WINID completion for herbstcommander
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/herbstcommander.sh | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/scripts/herbstcommander.sh b/scripts/herbstcommander.sh index eae3bb79..f15deac3 100755 --- a/scripts/herbstcommander.sh +++ b/scripts/herbstcommander.sh @@ -25,6 +25,7 @@ cmd=( "$@" ) forceexec=0 while :; do + dmenu_args="" if [[ "$forceexec" != 1 ]]; then completion=$($herbstclient_cmd complete "${#cmd[@]}" "${cmd[@]}") if [[ "$?" = 7 ]] ; then @@ -36,16 +37,45 @@ while :; do reply=$($herbstclient_cmd "${cmd[@]}") status=$? if [[ "$display_reply" && "$reply" ]]; then - $dmenu_cmd -p "${cmd[*]}" <<< "$reply" >/dev/null + $dmenu_cmd -p "${cmd[*]}" <<< "$reply" >/dev/null fi exit $status else - next=$($dmenu_cmd -p "${prompt}${cmd[*]}" <<< "$completion") + case "${cmd[*]}" in + raise|jumpto|bring) + tags=( $($herbstclient_cmd tag_status) ) + i=1 + completion=$( + wmctrl -l | while read line; do + fields=( $line ) + id=${fields[0]} + tag=${tags[ ${fields[1]} ]} + class=$(xprop -notype -id $id WM_CLASS | + sed 's/.*\?= *//; s/"\(.*\?\)", *"\(.*\?\)".*/\1,\2/') + title=${fields[@]:3} + printf "%-3s %s %-3s [%s] %s\n" "$i)" "$id" "$tag" "$class" "$title" + i=$((i+1)) + done + ) + + dmenu_args="-l 10" + ;; + esac + next=$($dmenu_cmd $dmenu_args -p "${prompt}${cmd[*]}" <<< "$completion") (( $? != 0 )) && exit 125 # dmenu was killed if [[ -z "$next" ]]; then - forceexec=1 # empty reply instead of cmpletion + forceexec=1 # empty reply instead of completion else - cmd+=( $next ) + case "${cmd[*]}" in + raise|jumpto|bring) + # add the WINID only (second field) + fields=( $next ) + cmd+=( ${fields[1]} ) + ;; + *) + cmd+=( $next ) + ;; + esac fi fi done |