git.lucas.co / fontpreview
git clone https://git.lucas.co/fontpreview.git

commit0cdf584c5dc3fbed2d1ae04e736a18c1458f154b
parent178a66fd18 66bd318f6f
authorMateusz Piotrowski <[email protected]>
date2020-02-17 00:59
Merge branch 'master' into master

 README.md      |  36 ++++++++++++++++++++++++++++--------
 extra/vifm.png | Bin 0 -> 129645 bytes
 fontpreview    |  33 +++++++++++++++++++++++++--------
 3 files changed, 53 insertions(+), 16 deletions(-)

diff --cc fontpreview
index 7c6522e,039327a..608f8b8
--- a/fontpreview
+++ b/fontpreview
@@@ -4,7 -4,13 +4,7 @@@
  #
  # Dependencies: sxiv, imagemagick, xdotool, fzf
  
- VERSION=1.0.3
 -# Use mktemp to create temporary files that won't
 -# collide with any other application's tmp files.
 -FONTPREVIEW_DIR="$(mktemp -d --tmpdir fontpreview_dir_XXXXXXXX)"
 -PIDFILE="$(mktemp --tmpdir="$FONTPREVIEW_DIR" fontpreview_XXXXXXXX.pid)"
 -FONT_PREVIEW="$(mktemp --tmpdir="$FONTPREVIEW_DIR" fontpreview_XXXXXXXX.png)"
 -TERMWIN_IDFILE="$(mktemp --tmpdir="$FONTPREVIEW_DIR" fontpreview_XXXXXXXX.termpid)"
+ VERSION=1.0.4
  
  # Default values
  SEARCH_PROMPT="❯ "
@@@ -100,9 -108,9 +102,9 @@@ main()
          # has pressed [ESCAPE]
          [[ -z $font ]] && return
  
-         generate_preview "$font"
+         generate_preview "$font" "$FONT_PREVIEW"
  
 -        if [ $FIRST_RUN == true ]; then
 +        if [[ $FIRST_RUN == true ]]; then
              FIRST_RUN=false
  
              # Display the font preview using sxiv
@@@ -118,13 -126,14 +120,13 @@@
              # sxiv when the user exits the script
              echo $! >"$PIDFILE"
  
- 	# Check for crashes of sxvi
 -	# Check for crashes of sxiv   
 -	elif [ -f $PIDFILE ] ; then
 -	    PID=$(cat $PIDFILE)
 -	    if  [ ! -e /proc/$PID ] ; then
++	# Check for crashes of sxiv
 +	elif [[ -f $PIDFILE ]] ; then
 +	    if ! pgrep -F "$PIDFILE" >/dev/null 2>&1; then
- 		echo "Restart sxvi - You maybe using a obsolete version. " >&2
+ 		echo "Restart sxiv - You maybe using a obsolete version. " >&2
  		# Display the font preview using sxiv
 -		sxiv -g "$SIZE$POSITION" "$FONT_PREVIEW" -N "fontpreview" -b &
 -		
 +		sxiv -g "$SIZE$POSITION" -N "fontpreview" -b "$FONT_PREVIEW" &
 +
  		# Change focus from sxiv, back to the terminal window
  		# so that user can continue to search for fonts without
  		# having to manually change focus back to the terminal window
@@@ -146,18 -155,8 +148,18 @@@ trap "" SIGTST
  
  trap pre_exit EXIT
  
 +# Use mktemp to create a temporary directory that won't
 +# collide with temporary files of other application.
 +FONTPREVIEW_DIR="$(mktemp -d "${TMPDIR:-/tmp}/fontpreview_dir.XXXXXXXX")" || exit
 +PIDFILE="$FONTPREVIEW_DIR/fontpreview.pid"
 +touch "$PIDFILE" || exit
 +FONT_PREVIEW="$FONTPREVIEW_DIR/fontpreview.png"
 +touch "$FONT_PREVIEW" || exit
 +TERMWIN_IDFILE="$FONTPREVIEW_DIR/fontpreview.termpid"
 +touch "$TERMWIN_IDFILE" || exit
 +
  # Parse the arguments
- options=$(getopt -o h --long position:,size:,version,search-prompt:,font-size:,bg-color:,fg-color:,preview-text:,help -- "$@")
+ options=$(getopt -o hi:o: --long position:,size:,version,search-prompt:,font-size:,bg-color:,fg-color:,preview-text:,input:,output:,help -- "$@")
  eval set -- "$options"
  
  while true; do