logo

utils

~/.local/bin tools and git-hooks
commit: ac3400a968c0f12f61633cdc19f22e62cc863b3c
parent 38d6e3bbb92ebef8de19c870c333f5a40a3bcae9
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue,  3 Nov 2020 02:42:00 +0100

bin/dmenu_path: New executable

Diffstat:

Abin/Makefile.config1+
Abin/dmenu_path18++++++++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/bin/Makefile.config b/bin/Makefile.config @@ -0,0 +1 @@ +EXE = args date echo lolcat pwd range sizeof xcd dmenu_path diff --git a/bin/dmenu_path b/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 | sort -u | tee "$cache" +else + cat "$cache" +fi