commit: 7fe00d698172f3a1d07a402e83e02756358aa1f5
parent 75c409e1c57c19a41c5ab8e2e0836c411622a61d
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Tue, 1 Dec 2020 23:06:07 +0100
dmenu_path: Add
Diffstat:
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git a/.local/bin/dmenu_path b/.local/bin/dmenu_path
@@ -0,0 +1,18 @@
+#!/bin/sh
+# Port of suckless's dmenu_path(1) to pure POSIX
+
+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
+
+test -f "${cache}" || touch -d 1970-01-01T00:00:00 "${cache}"
+
+IFS=:
+if [ "$(find $PATH -type d -newer "$cache" 2>/dev/null | wc -l)" != "0" ]; then
+ find $PATH -type f -perm -o=rx 2>/dev/null | while read file; do basename "$file"; done | sort -u | tee "$cache"
+else
+ cat "$cache"
+fi