Advertisement
Guest User

dmenu_files

a guest
Dec 22nd, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.66 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. locatedb=/var/lib/mlocate/mlocate.db # 'locate' database file, very likely here
  4. cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
  5.  
  6. if [ -d "$cachedir" ]
  7. then
  8.         cache=$cachedir/dmenu_open
  9. else # if no xdg dir, fall back to dotfile in ~
  10.         cache=$HOME/.dmenu_open
  11. fi
  12.  
  13. if [ ! -f "$cache" ] || [ "$cache" -ot "$locatedb" ]
  14. # ie: if the cache file exists OR if the cache is older than the lcoatedb
  15. then
  16.         nohidden="/\/\./d"      # removes all hidden files from the list
  17.         striphome="s#$HOME/##"  # strips home directory suffix
  18.         locate -r "^$HOME/" | sed "$nohidden; $striphome" | tee "$cache"
  19. else
  20.         cat "$cache"
  21. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement