summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorThorsten Wißmann <edu@thorsten-wissmann.de>2011-10-01 22:55:23 +0200
committerThorsten Wißmann <edu@thorsten-wissmann.de>2011-10-01 22:55:36 +0200
commit9d00b0d96b24b8a2c8c43803da6de4ee56f65ade (patch)
treead926cdcde8a8f6bcdb153156c5da7c7964c3329 /scripts
parent2f3fb7749b1de6c2a153dffb93e9cbdb565d5b59 (diff)
added herbstcommander.sh script
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/herbstcommander.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/herbstcommander.sh b/scripts/herbstcommander.sh
new file mode 100755
index 00000000..3a99f294
--- /dev/null
+++ b/scripts/herbstcommander.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+# 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}
+herbstclient_cmd=${herbstclient_cmd:-herbstclient}
+prompt=${prompt:-herbstluft: }
+display_reply=${display_reply:-true}
+
+cmd=()
+
+while :; do
+ completion=$(herbstclient complete "${#cmd[@]}" "${cmd[@]}")
+ if [[ -z "$completion" ]]; then
+ echo "Executing ${cmd[@]}"
+ reply=$(herbstclient "${cmd[@]}")
+ status=$?
+ if [[ "$display_reply" && "$reply" ]]; then
+ dmenu -p "${cmd[*]}" <<< "$reply" >/dev/null
+ fi
+ exit $status
+ else
+ cmd+=( $(dmenu -p "herbstluft: ${cmd[@]}" <<< "$completion") )
+ (( $? != 0 )) && exit 125 # dmenu was killed
+ fi
+done