[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] WINID completion for herbstcommander
- To: herbstluftwm _minus_ devel _at_ lists _dot_ sourceforge _dot_ net
- Subject: [PATCH] WINID completion for herbstcommander
- From: Gabor Adam Toth <tg _at_ tgbit _dot_ net>
- Date: Tue, 25 Sep 2012 10:59:14 +0200
---
scripts/herbstcommander.sh | 39 +++++++++++++++++++++++++++++++++++----
1 file changed, 35 insertions(+), 4 deletions(-)
diff --git a/scripts/herbstcommander.sh b/scripts/herbstcommander.sh
index 77e8c3f..2caebc4 100755
--- a/scripts/herbstcommander.sh
+++ b/scripts/herbstcommander.sh
@@ -26,6 +26,7 @@ cmd=( "$@" )
forceexec=0
while :; do
+ dmenu_args=""
if [[ "$forceexec" != 1 ]]; then
completion=$($herbstclient_cmd complete "${#cmd[ _at_ ]}" "${cmd[ _at_ ]}")
if [[ "$?" = 7 ]] ; then
@@ -37,16 +38,46 @@ while :; do
reply=$($herbstclient_cmd "${cmd[ _at_ ]}")
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 -lp | while read line; do
+ fields=( $line )
+ id=${fields[0]}
+ tag=${tags[ ${fields[1]} ]}
+ comm=$(ps -o comm= ${fields[2]})
+ title=${fields[ _at_ ]:4}
+ if [ $i -gt 1 ]; then
+ echo
+ fi
+ printf "%2d) %s %-3s [%s] %s" $i $id $tag $comm "$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
--
1.7.12