diff options
author | Steph Enders <smenders@gmail.com> | 2022-12-24 10:48:30 -0500 |
---|---|---|
committer | Steph Enders <steph@senders.io> | 2024-06-24 12:57:54 -0400 |
commit | eba1b09b5b72806d90dc255f3dba1eb573fa9c08 (patch) | |
tree | 68ee670f9378d5e631b2510bca4d02e273f2350d | |
parent | 2b43dd013a22fc94519b70024f0ad1512d422848 (diff) |
add patch: dmenu_omit - filter omitted entries
dmenu_omit is a filtering tool that appends any supplied entries to a
list of items to filter from the dmenu result. This allows the user to
remove troublesome items that exist in path, that need to exist in path,
but are useless from dmenu.
dmenu_omit is the command line tool to append these items to the list.
dmenu_path was modified to filter based on the items in this list.
dmenu_omitlist is the file stored in your configdir containing these
files.
Makefile was updated to install/uninstall the dmenu_omit
-rw-r--r-- | FORK_PATCHES | 26 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rwxr-xr-x | dmenu_omit | 22 | ||||
-rwxr-xr-x | dmenu_path | 5 |
4 files changed, 55 insertions, 2 deletions
diff --git a/FORK_PATCHES b/FORK_PATCHES index 63cb614..408ba23 100644 --- a/FORK_PATCHES +++ b/FORK_PATCHES @@ -5,3 +5,29 @@ This is my local fork with some patches applied and maintained = Patches +== Filtered Entries + +Manually applied a filter to the pipe arguments to omit certain entries. +Rather than supplying a filtered list, or biasing on recency, this patch omits +anything that is contained in the supplied configuration file: + $XDG_CONFIG_DIR or $HOME/.config/dmenu/dmenu_omitlist + +A simple text file that is passed into dmenu_path to filter any items you wish +to remove. Each path-item name is placed one per line. + +The idea being that - dmenu is useful to have /everything/ available in it. But +some items that you would never call clash with a preinstalled program e.g: + fire (a graphics demo) would make it so, after getting installed by mesa, +filtering for firefox you would need a minimum entry of firef which may break +what you're muscle memory is use to. Simple push fire into you list and you're +good :) + +It also provide a command line tool to help add filter items from your shell: + dmenu_omit fire +will enter that item and sort your list. + +I don't know how portable this is since I wanted to omit the whitespace and that +required the usage of grep -E (which I know isn't the most portable). Feel free +to edit dmenu_omit and either supply a cross *nix way, or simply remove the +whitespace logic from the patch + @@ -36,8 +36,9 @@ dist: clean install: all mkdir -p $(DESTDIR)$(PREFIX)/bin - cp -f dmenu dmenu_path dmenu_run stest $(DESTDIR)$(PREFIX)/bin + cp -f dmenu dmenu_omit dmenu_path dmenu_run stest $(DESTDIR)$(PREFIX)/bin chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu + chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_omit chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_path chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_run chmod 755 $(DESTDIR)$(PREFIX)/bin/stest @@ -49,6 +50,7 @@ install: all uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/dmenu\ + $(DESTDIR)$(PREFIX)/bin/dmenu_omit\ $(DESTDIR)$(PREFIX)/bin/dmenu_path\ $(DESTDIR)$(PREFIX)/bin/dmenu_run\ $(DESTDIR)$(PREFIX)/bin/stest\ diff --git a/dmenu_omit b/dmenu_omit new file mode 100755 index 0000000..d07d8f8 --- /dev/null +++ b/dmenu_omit @@ -0,0 +1,22 @@ +#!/bin/sh + +configdir="${XDG_CONFIG_HOME:-"$HOME/.config/dmenu"}" +config="$configdir/dmenu_omitlist" + +[ ! -e "$configdir" ] && mkdir -p "$configdir" + +if [ $# -lt 1 ]; then + echo "Missing argument(s). + Usage: dmenu_omit item" >&2 + exit 1 +fi + +for item in "$@" +do + echo "$item" >> $config +done + +# using grep to filter out any blanks or empty lines +# useful if manually edited +cat -s $config | grep -v -E '^([[:space:]])*$' | sort -u -o $config + @@ -2,12 +2,15 @@ cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}" cache="$cachedir/dmenu_run" +configdir="${XDG_CONFIG_HOME:-"$HOME/.config/dmenu"}" +config="$configdir/dmenu_omitlist" [ ! -e "$cachedir" ] && mkdir -p "$cachedir" +[ ! -e "$configdir" ] && mkdir -p "$configdir" IFS=: if stest -dqr -n "$cache" $PATH; then - stest -flx $PATH | sort -u | tee "$cache" + stest -flx $PATH | sort -u | grep -wvF -f $config | tee "$cache" else cat "$cache" fi |