summaryrefslogtreecommitdiff
path: root/dmenu/dmenu_path
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-02-09 10:19:46 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-02-09 10:19:46 +0900
commitb9d337f3c0ca2501744a1bb12b9bd6d3929c692c (patch)
treedd312fea6046764464b93cb3464b9b260bb3062f /dmenu/dmenu_path
parent0bbc6ee96491c8f9619148018214427d8ca026b4 (diff)
updates
Diffstat (limited to 'dmenu/dmenu_path')
-rwxr-xr-xdmenu/dmenu_path21
1 files changed, 10 insertions, 11 deletions
diff --git a/dmenu/dmenu_path b/dmenu/dmenu_path
index 3a7cda7..9b3b1f2 100755
--- a/dmenu/dmenu_path
+++ b/dmenu/dmenu_path
@@ -1,13 +1,12 @@
#!/bin/sh
+#
+# dmenu_path: Override dmenu_path sorting results by atime.
+#
+# By default, dmenu_path sorts executables alphabetically. It seems to make
+# more sense to sort them by atime in an effort to reduce the number of
+# keystrokes needed to start a program.
-cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}"
-cache="$cachedir/dmenu_run"
-
-[ ! -e "$cachedir" ] && mkdir -p "$cachedir"
-
-IFS=:
-if stest -dqr -n "$cache" $PATH; then
- stest -flx $PATH | sort -u | tee "$cache"
-else
- cat "$cache"
-fi
+echo $PATH | tr ':' '\n' | uniq | sed 's#$#/#' | # List directories in $PATH
+ xargs ls -lu --time-style=+%s | # Add atime epoch
+ awk '/^(-|l)/ { print $6, $7 }' | # Only print timestamp and name
+ sort -rn | cut -d' ' -f 2