diff options
author | Toby Vincent <tobyv@tobyvin.dev> | 2024-06-10 19:38:46 -0500 |
---|---|---|
committer | Toby Vincent <tobyv@tobyvin.dev> | 2024-06-10 19:38:46 -0500 |
commit | 99702320922e5525ef1bad2bf6c2807fa479e573 (patch) | |
tree | 10abde6ae67825b73aa86e41a441f9bfdd2f880d /sway/.local/bin/sway-menu-run | |
parent | b81844cec87c0a0771f6bff7bb8682846db67a72 (diff) |
fix(sway): fix sway-menu-run
Diffstat (limited to 'sway/.local/bin/sway-menu-run')
-rwxr-xr-x | sway/.local/bin/sway-menu-run | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sway/.local/bin/sway-menu-run b/sway/.local/bin/sway-menu-run new file mode 100755 index 0000000..318e54d --- /dev/null +++ b/sway/.local/bin/sway-menu-run @@ -0,0 +1,34 @@ +#!/bin/sh + +cache_dir="${XDG_CACHE_HOME:-"$HOME/.cache"}" +cache="$cache_dir/sway-menu-run" + +uptodate() { + IFS=: + for path in $PATH; do + if test "$path" -nt "$cache"; then + return 1 + fi + done + + return 0 +} + +get_bin() { + IFS=: + for path in $PATH; do + for bin in "$path"/*; do + if [ -x "$bin" ]; then + echo "${bin##*/}" + fi + done + done +} + +[ ! -e "$cache_dir" ] && mkdir -p "$cache_dir" + +if [ ! -e "$cache" ] || ! uptodate; then + get_bin | sort -u | tee "$cache" | sway-menu +else + cat "$cache" +fi |