#!/bin/sh # cb-recent-files-pipemenu - a script to parse .recently-used.xbel # and generate openbox pipe menu # Copyright (C) 2010 John Crawley # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # version 2012/07/01-cb # Ported to #!++ # by Ben Young # Ported to Manjaro # by Daniel Napora # Usage: add # # to your .config/openbox/menu.xml, or use with mabox-places-pipemenu (see comments there) maximum_entries=15 # max. number of entries in menu ####################################################################### case $LANG in pl*) NOTFOUND="Nie znaleziono pliku recently-used.xbel" ;; *) NOTFOUND="Cannot find a readable recently-used.xbel file" ;; esac # look for recently-used.xbel if [ $XDG_DATA_HOME ] && [ -r "${XDG_DATA_HOME}/recently-used.xbel" ] then file_path="${XDG_DATA_HOME}/recently-used.xbel" elif [ -r "${HOME}/.local/share/recently-used.xbel" ] then file_path="${HOME}/.local/share/recently-used.xbel" elif [ -r "${HOME}/.recently-used.xbel" ] then file_path="${HOME}/.recently-used.xbel" else echo "$0: cannot find a readable recently-used.xbel file" >&2 echo ' ' exit 1 fi # if argument is --clear, empty .recently-used.xbel [ "$1" = '--clear' ] && { cat <<':EOF' > "${file_path}" :EOF exit } maximum_entries=$((maximum_entries+2)) pre=' ' post=' ' files=$( tac "${file_path}" | awk -v MAX="$maximum_entries" -v PR="$pre" -v MI="$mid" -v PO="$post" 'BEGIN { RS=""; FS=""; } (NR == MAX) {exit} !/ ''"$0"'' --clear ' printf '%s' "$output" # printf because echo sometimes eats backslashes