summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2011-11-15 19:48:33 +0100
committerThorsten Wißmann <edu@thorsten-wissmann.de>2011-11-15 20:37:41 +0100
commitd09ba694f9fca0080e549df77bcaabe02140e73c (patch)
tree1d27883fc7c2cd8da1870aa3314ef141f4d15966 /scripts
parent51176a6ff897b9c0c099a4deb99f410afa6d54b8 (diff)
Several herbstcommander fixes and additions
- If a dmenu was closed with an empty reply (e.g. Shift+Enter) the command is executed (useful for optional arguments) - Search config file in $HOME/.config/herbstluftwm as well, not only in $XDG_CONFIG_HOME - Actually use $dmenu_cmd and $herbstclient_cmd - Accept arguments to the script as arguments to dmenu - Add some documentation about how to change colors
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/herbstcommander.sh35
1 files changed, 27 insertions, 8 deletions
diff --git a/scripts/herbstcommander.sh b/scripts/herbstcommander.sh
index 369423d6..9b859ed9 100755
--- a/scripts/herbstcommander.sh
+++ b/scripts/herbstcommander.sh
@@ -3,27 +3,46 @@
# herbstcommander.sh - launch herbstluftwm-commands via dmenu
# Written by Florian Bruhin <me@the-compiler.org>
-config="$XDG_CONFIG_HOME/herbstluftwm/herbstcommander"
-[[ -f "$config" ]] && source "$config"
-dmenu_cmd=${dmenu_cmd:-dmenu}
+# To customize dmenu-colors, create a file named "herbstcommander" in your
+# herbstluftwm config-directory, with something like this in it:
+#
+# dmenu_cmd="dmenu -i -b -nb #313131 -nf #686868 -sb #454545 -sf #898989"
+#
+# You can also directly pass dmenu-arguments to this script instead, as long
+# as dmenu_cmd is undefined.
+
+config_1="$XDG_CONFIG_HOME/herbstluftwm/herbstcommander"
+config_2="$HOME/.config/herbstluftwm/herbstcommander"
+[[ -f "$config_1" ]] && source "$config_1"
+[[ -f "$config_2" ]] && source "$config_2"
+
+dmenu_cmd=${dmenu_cmd:-dmenu $@}
herbstclient_cmd=${herbstclient_cmd:-herbstclient}
prompt=${prompt:-herbstluft: }
display_reply=${display_reply:-true}
cmd=()
+forceexec=0
while :; do
- completion=$(herbstclient complete "${#cmd[@]}" "${cmd[@]}")
- if [[ -z "$completion" ]]; then
+ if [[ "$forceexec" != 1 ]]; then
+ completion=$($herbstclient_cmd complete "${#cmd[@]}" "${cmd[@]}")
+ fi
+ if [[ -z "$completion" || "$forceexec" == 1 ]]; then
echo "Executing ${cmd[@]}"
- reply=$(herbstclient "${cmd[@]}")
+ reply=$($herbstclient_cmd "${cmd[@]}")
status=$?
if [[ "$display_reply" && "$reply" ]]; then
- dmenu -p "${cmd[*]}" <<< "$reply" >/dev/null
+ $dmenu_cmd -p "${cmd[*]}" <<< "$reply" >/dev/null
fi
exit $status
else
- cmd+=( $(dmenu -p "${prompt}${cmd[*]}" <<< "$completion") )
+ next=$($dmenu_cmd -p "${prompt}${cmd[*]}" <<< "$completion")
(( $? != 0 )) && exit 125 # dmenu was killed
+ if [[ -z "$next" ]]; then
+ forceexec=1 # empty reply instead of cmpletion
+ else
+ cmd+=( $next )
+ fi
fi
done