Re: [dev] [dmenu] sorted unlimited history

From: Peter Hartman <peterjohnhartman_AT_gmail.com>
Date: Mon, 11 Mar 2013 16:37:41 -0400

2013/3/11 Chris Johnson <raugturi_AT_gmail.com>:
> I created a patch to have sorted (first by number of previous runs, then by
> most recent) and unlimited history. It is similar to the patch from Peter
> John Hartman, but modified in the following ways:

Hi Chris,

That's neat. I moved to using a shell script wrapper to dmenu to do
history --- I believe those scripts are on the website --- but it
won't do the neat trick of moving things to the top based on how often
they are used. I'd advocate something like this get moved into dmenu
tip.

It'd also be nice (more generally, even without the history patch, but
especially with it) to have a check to verify that the file still
exists. For instance, I use the history feature on dmenu when I open
pdf files on my system, e.g. [1] where .dmenu_cache_pdfs is generated
via a cron script. But, of course, sometimes I will move or rename
pdf files around, and then the history file will be all dumb. It'd be
a one-line fix.

[1] pdf-opener

#!/bin/bash
HISTFILE=~/.dmenu_cache_pdfs.hist
CACHEFILE=~/.dmenu_cache_pdfs
exe=$(tac $HISTFILE $CACHEFILE | sed 's|^/home/peterjh/||'| dmenu -p
"*" -i -l 10)

echo "$exe"
case "$exe" in
 o*) opt="okular"
     exe=$(echo "$exe" | sed 's/^o //')
 ;;
 *) opt="mailcap"
 ;;
esac

if [ ! -f "/home/peterjh/$exe" ] ; then
  exit
fi

if [ $? -eq 0 ]; then
        exe="/home/peterjh/$exe"
        sed -i "\|$exe|d" $HISTFILE
        echo "$exe" >> $HISTFILE
        case "$opt" in
          okular)
            okular "$exe" &
            ;;
          mailcap)
              run-mailcap "$exe" &
              ;;
    esac
fi




-- 
sic dicit magister P
Université du Québec à Montréal / Loyola University Chicago
http://individual.utoronto.ca/peterjh
gpg 1024D/ED6EF59B (7D1A 522F D08E 30F6 FA42 B269 B860 352B ED6E F59B)
gpg --keyserver pgp.mit.edu --recv-keys ED6EF59B
Received on Mon Mar 11 2013 - 21:37:41 CET

This archive was generated by hypermail 2.3.0 : Mon Mar 11 2013 - 21:48:05 CET