Added dmenu_terminal (to launch cli programs) and dmenu_run_history (to sort by history the output of dmenu)
This commit is contained in:
parent
72c2aeca25
commit
db7d535034
6
Makefile
6
Makefile
|
@ -34,7 +34,7 @@ clean:
|
|||
dist: clean
|
||||
mkdir -p dmenu-$(VERSION)
|
||||
cp LICENSE Makefile README arg.h config.def.h config.mk dmenu.1\
|
||||
drw.h util.h dmenu_path dmenu_run dmenu_terminal stest.1 $(SRC)\
|
||||
drw.h util.h dmenu_path dmenu_run dmenu_terminal dmenu_run_history stest.1 $(SRC)\
|
||||
dmenu-$(VERSION)
|
||||
tar -cf dmenu-$(VERSION).tar dmenu-$(VERSION)
|
||||
gzip dmenu-$(VERSION).tar
|
||||
|
@ -42,11 +42,12 @@ dist: clean
|
|||
|
||||
install: all
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
||||
cp -f dmenu dmenu_path dmenu_run dmenu_terminal stest $(DESTDIR)$(PREFIX)/bin
|
||||
cp -f dmenu dmenu_path dmenu_run dmenu_terminal dmenu_run_history stest $(DESTDIR)$(PREFIX)/bin
|
||||
chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu
|
||||
chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_path
|
||||
chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_run
|
||||
chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_terminal
|
||||
chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_run_history
|
||||
chmod 755 $(DESTDIR)$(PREFIX)/bin/stest
|
||||
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
|
||||
sed "s/VERSION/$(VERSION)/g" < dmenu.1 > $(DESTDIR)$(MANPREFIX)/man1/dmenu.1
|
||||
|
@ -59,6 +60,7 @@ uninstall:
|
|||
$(DESTDIR)$(PREFIX)/bin/dmenu_path\
|
||||
$(DESTDIR)$(PREFIX)/bin/dmenu_run\
|
||||
$(DESTDIR)$(PREFIX)/bin/dmenu_terminal\
|
||||
$(DESTDIR)$(PREFIX)/bin/dmenu_run_history\
|
||||
$(DESTDIR)$(PREFIX)/bin/stest\
|
||||
$(DESTDIR)$(MANPREFIX)/man1/dmenu.1\
|
||||
$(DESTDIR)$(MANPREFIX)/man1/stest.1
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
#!/bin/sh
|
||||
|
||||
cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
|
||||
if [ -d "$cachedir" ]; then
|
||||
cache=$cachedir/dmenu_run
|
||||
historyfile=$cachedir/dmenu_history
|
||||
else # if no xdg dir, fall back to dotfiles in ~
|
||||
cache=$HOME/.dmenu_cache
|
||||
historyfile=$HOME/.dmenu_history
|
||||
fi
|
||||
|
||||
IFS=:
|
||||
if stest -dqr -n "$cache" $PATH; then
|
||||
stest -flx $PATH | sort -u > "$cache"
|
||||
fi
|
||||
unset IFS
|
||||
|
||||
awk -v histfile=$historyfile '
|
||||
BEGIN {
|
||||
while( (getline < histfile) > 0 ) {
|
||||
sub("^[0-9]+\t","")
|
||||
print
|
||||
x[$0]=1
|
||||
}
|
||||
} !x[$0]++ ' "$cache" \
|
||||
| dmenu "$@" \
|
||||
| awk -v histfile=$historyfile '
|
||||
BEGIN {
|
||||
FS=OFS="\t"
|
||||
while ( (getline < histfile) > 0 ) {
|
||||
count=$1
|
||||
sub("^[0-9]+\t","")
|
||||
fname=$0
|
||||
history[fname]=count
|
||||
}
|
||||
close(histfile)
|
||||
}
|
||||
|
||||
{
|
||||
history[$0]++
|
||||
print
|
||||
}
|
||||
|
||||
END {
|
||||
if(!NR) exit
|
||||
for (f in history)
|
||||
print history[f],f | "sort -t '\t' -k1rn >" histfile
|
||||
}
|
||||
' \
|
||||
| while read cmd; do ${SHELL:-"/bin/sh"} -c "$cmd" & done
|
Loading…
Reference in New Issue