git clone https://git.lucas.co/fontpreview.git
# ISSUE #7: Handle crashes of sxvi on recreation of preview image in obsolete versions still in use in some distros.
fontpreview | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/fontpreview b/fontpreview
index 382ce4f..089fce0 100755
--- a/fontpreview
+++ b/fontpreview
@@ -123,7 +123,27 @@ main(){
# Save the process ID so that we can kill
# sxiv when the user exits the script
echo $! >"$PIDFILE"
- fi
+
+ # Check for crashes of sxvi
+ elif [ -f $PIDFILE ] ; then
+ PID=$(cat $PIDFILE)
+ ls -1 /proc/$PID >&2
+ if [ ! -e /proc/$PID ] ; then
+ echo "Restart sxvi - You maybe using a obsolete version. " >&2
+ # Display the font preview using sxiv
+ sxiv -g "$SIZE$POSITION" "$FONT_PREVIEW" -N "fontpreview" -b &
+
+ # 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
+ xdotool windowfocus "$(cat "$TERMWIN_IDFILE")"
+
+ # Save the process ID so that we can kill
+ # sxiv when the user exits the script
+ echo $! >"$PIDFILE"
+ fi
+
+ fi
done
}