Heyhey
I kept thinking about a more general way to implement history
functionality for dmenu and this is what I came up with.
We use the sort command to generate an input list for dmenu sorted by
count (first patch). dmenu itself is not modified and shows the available
commands with the most often used ones first (due to the sorting done
by sort). Before sending the dmenu output to a shell we use a simple
C program that reads a command from stdin for which it increments the
usage count in the history file before sending the command to the shell
to execute (patch 4; rest of the patches are just glue code).
Issues with this approach:
* It uses the -t and -k options of sort which are not available for
all sort implementations (not in sbase for example). If there is an
easy way to replicate this functionality without using these sort
options I would like to hear about it.
* Because the regular list of commands is still sent to dmenu, all the
ones in the history file will be present twice. As long as you use only
the most often used commands that should not matter (unless you are
bothered by the same command being shown twice next to each other when
you filter out enough of the more rarely used ones).
* The updhist program would be a good candidate to be implemented in a
scripting language since it's so simple. Ideally it would be a small one
like awk but I could not figure out how to make awk's string matching
depend on some input other than the input file itself. Suggestions
are welcome!
Silvan Jegen (4):
Use sort to generate the command list
Pass a file path to dmenu_path and run updhist
Add updhist to the Makefile
Add the updhist program
Makefile | 12 ++++++---
dmenu_path | 12 +++++++--
dmenu_run | 5 +++-
updhist.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 106 insertions(+), 7 deletions(-)
mode change 100644 => 100755 dmenu_path
create mode 100644 updhist.c
--
2.6.2
Received on Fri Nov 27 2015 - 19:38:28 CET