[PATCH 4/4] Add share/dmenu_run_hlwm

Florian Schmaus flo at geekplace.eu
Wed Jun 25 11:33:55 CEST 2014


---
 Makefile             |  2 ++
 share/dmenu_run_hlwm | 38 ++++++++++++++++++++++++++++++++++++++
 www/faq.txt          | 22 ++++++++++++++++++++--
 3 files changed, 60 insertions(+), 2 deletions(-)
 create mode 100755 share/dmenu_run_hlwm

diff --git a/Makefile b/Makefile
index 43ac860..ebaf151 100644
--- a/Makefile
+++ b/Makefile
@@ -125,6 +125,7 @@ install-nodoc: all-nodoc
 	$(INSTALL) -m 644 share/herbstclient-completion '$(DESTDIR)$(BASHCOMPLETIONDIR)/'
 	$(INSTALL) -m 644 share/_herbstclient '$(DESTDIR)$(ZSHCOMPLETIONDIR)/'
 	$(INSTALL) -m 644 share/herbstluftwm.desktop '$(DESTDIR)$(XSESSIONSDIR)/'
+	$(INSTALL) -m 755 share/dmenu_run_hlwm '$(DESTDIR)$(BINDIR)/'
 	$(INSTALL) -m 644 scripts/README '$(DESTDIR)$(EXAMPLESDIR)/'
 	$(INSTALL) -m 755 scripts/*.sh '$(DESTDIR)$(EXAMPLESDIR)/'
 
@@ -133,6 +134,7 @@ install-nodoc: all-nodoc
 uninstall:
 	@echo "==> deleting files..."
 	-$(foreach TARGET,$(TARGETS),$(RM) '$(DESTDIR)$(BINDIR)/$(TARGET)';)
+	-$(RM) '$(DESTDIR)$(BINDIR)/dmenu_run_hlwm'
 	-$(RM) '$(DESTDIR)$(LICENSEDIR)/LICENSE'
 	-$(RM) '$(DESTDIR)$(MAN1DIR)/herbstclient.1'
 	-$(RM) '$(DESTDIR)$(MAN1DIR)/herbstluftwm.1'
diff --git a/share/dmenu_run_hlwm b/share/dmenu_run_hlwm
new file mode 100755
index 0000000..ec20972
--- /dev/null
+++ b/share/dmenu_run_hlwm
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+if ! command -v dmenu > /dev/null 2>/dev/null ; then
+	echo "Error: Requirement dmenu not found in your PATH." >&2
+	exit 1
+fi
+
+# Get the currently active tag
+tag=$(herbstclient attr tags.focus.name)
+
+# Prints the path of of the binary in path selected by dmenu
+dmenuPrintPath() {
+	cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
+	if [ -d "$cachedir" ]; then
+		cache=$cachedir/dmenu_run
+	else
+		cache=$HOME/.dmenu_cache # if no xdg dir, fall back to dotfile in ~
+	fi
+	IFS=:
+	if stest -dqr -n "$cache" $PATH; then
+		stest -flx $PATH | sort -u | tee "$cache" | dmenu "$@"
+	else
+		dmenu "$@" < "$cache"
+	fi
+}
+
+selectedPath=$(dmenuPrintPath)
+
+# Ensure that the tag exists
+herbstclient add "$tag"
+
+# Move next window from this process to this tag. Prepend the rule so
+# that it may be overwritten by existing custom rules e.g. in the
+# autostart. Also set a maximum age for this rule of 120 seconds and
+# mark it as one-time-only rule.
+herbstclient rule prepend maxage="120" pid="$$" tag="$tag" once
+
+exec $selectedPath
diff --git a/www/faq.txt b/www/faq.txt
index 354be69..fbe5e3d 100644
--- a/www/faq.txt
+++ b/www/faq.txt
@@ -123,7 +123,13 @@ hc rule class=Gimp windowrole=gimp-dock focus=off index=1
 
 Q: What about an layout for Instant Messaging applications (Gajim, Pidgin, …)?
 ------------------------------------------------------------------------------
-A good layout for Instant Messaging applications where one frame on the left displays the roster, consuming ~15% of the monitor space, while the right side is used for the conversations can be configured easily with herbstluftwm. The following example configures such a layout on tag '7' and creates the rules to automatically move Gajim's windows to the right frame:
+
+A good layout for Instant Messaging applications. where one frame on
+the left displays the roster and consuming ~15% of the monitor space
+while the right side is used for the conversations, can be configured
+easily with herbstluftwm. The following example configures such a
+layout on tag '7' and creates the rules to automatically move Gajim's
+windows to the right frame:
 
 ----
 hc load 7 '(split horizontal:0.15:1 (clients horizontal:0) (clients grid:4))'
@@ -131,7 +137,6 @@ hc rule class="Gajim" tag=7 index=1
 hc rule class="Gajim" windowrole="roster" tag=7 index=0
 ----
 
-
 [[TEMP_RULES]]
 Q: How can I add rules temporarily for some special clients?
 ------------------------------------------------------------
@@ -250,3 +255,16 @@ Q: I'm using a compositing manager like xcompmgr and get ugly artifacts when swi
 You probably have an old version of herbstluftwm and +frame_bg_transparent+
 enabled. Disable this setting and use +frame_active_opacity+ and/or
 +frame_normal_opacity+ instead or upgrade to the current git version.
+
+Q: How can I keybind a simple "Run" dialog?
+-------------------------------------------
+Install dmenu and keybind +dmenu_run_hlwm+ by adding the following line to
+your autostart file:
+
+----
+hc keybind $Mod-p spawn dmenu_run_hlwm
+----
+
+Note that +$Mod-p+ is bound to +pseudotile toggle+ in the default
+autostart of herbstluftwm, so you either need to change that binding or
+use a different one for +spawn dmenu_run_hlwm+.
-- 
1.9.1




More information about the hlwm mailing list