[download]

local/bin/recentmenu

   1 #!/bin/bash
   2 
   3 print(){ # {{{
   4     command -v $1 > /dev/null || return
   5 
   6     uniq | while read i; do
   7         i=${i/\~/~}
   8         i=${i/\$HOME/~}
   9 
  10         [[ -f $i ]] && printf '%s\t%s\n' $1 "$i"
  11     done | sed "${limit}q; s:$HOME:~:"
  12 } # }}}
  13 start(){ # {{{
  14     while read _ a b; do
  15         $a "${b/\~/~}" &
  16         pidof -q $a || sleep 0.2
  17     done < <(
  18         awk '!a[$0]++'   |
  19         column -ts $'\t' |
  20         icon -x recent   |
  21         menu -i recent -l 20
  22     )
  23 } # }}}
  24 
  25 [[ $1 == -l && $2 -gt 0 ]] &&
  26 limit=$2 || limit=5
  27 
  28 while IFS=\| read exec file; do
  29     file=${file#file://}
  30     file=$(echo -e "${file//%/\\x}")
  31 
  32     [[ $exec == *godot*    ]] && godot+=("$file")
  33     [[ $exec == *inkscape* ]] && inkscape+=("$file")
  34     [[ $exec == *gimp*     ]] && gimp+=("$file")
  35     [[ $exec == *audacity* ]] && audacity+=("$file")
  36     [[ $exec == *chromium* ]] && chromium+=("$file")
  37 done < <( # {{{
  38     cat ~/.local/share/recently-used.xbel |
  39     awk -F \" '
  40         /href="/ { file = $2 }
  41         /exec="/ { exec = $4 }
  42         /modified="/ { time = $6 }
  43 
  44         /<bookmark:application / {
  45             printf "%s\t%s|%s\n", time, exec, file
  46         }
  47     ' | sort -r | cut -f 2-
  48 ) # }}}
  49 
  50 {
  51 
  52     test -f ~/.vim/viminfo || : ~/.viminfo
  53     grep '^>' $_ | cut -c 3- | print gvim
  54 
  55     printf '%s\n' "${godot[@]}"    | print godot
  56     printf '%s\n' "${inkscape[@]}" | print inkscape
  57 
  58     sed '1,/Fireworks.*Recent File List/d; /^$/,$d' ~/.wine/user.reg    |
  59     sort -V | grep ^\"File | cut -d \" -f 4 | sed 's|z:||I; s|\\\\|/|g' |
  60     while read -r i; do echo -e "${i//\\x/\\u}"; done | print fireworks
  61 
  62     cat ~/.config/blender/*/config/recent-files.txt | print blender
  63     sort -Vr ~/.config/kritarc | grep ^File | cut -d = -f 2 | print krita
  64 
  65     printf '%s\n' "${gimp[@]}"     | print gimp
  66     printf '%s\n' "${audacity[@]}" | print audacity
  67     printf '%s\n' "${chromium[@]}" | print chromium
  68 
  69 } | start