sdushantha/fontpreview

Only works with one font at a time

SebastianMeisel opened this issue · 24 comments

For me the font preview works only for one font. When I want to preview a second font I have to quit and restart the script.

Ubuntu 18.04
bash 4.4.20

Could you please send a screen recording so that I can see what is happening?

Hmm...seems like there is nothing. I think it is not showing up because you replied by email.
image

I had to zip it, so github accepts it.
vokoscreen-2020-02-08_21-11-56.zip

Ah okay, now I see what the problem is.
I have configured sxiv to be floating window. You have it so that it fills to whole screen. The problem here is that when you are quitting sxiv, and you arent supposed to do that.

Is it possible to set in your window manager to not have a window full screen?

Having same issue using floating window

Video:
screenrecord

i3-gaps: 4.15.0.1
bash: 4.4.12

Strange..

@nilskuehme do you use Ubuntu or similar?

I'm having the same issue, also with a Ubuntu derivative.
I believe the problem stems from sxiv being an obsolete version in the Ubuntu repos. The next version after the one I have (1.3.2-1) says the following in the change log:

https://github.com/muennich/sxiv

v24 (October 27, 2017)
Automatically reload the current image whenever it changes

Also, the following:

Please make sure to install the corresponding development packages in case that you want to build sxiv on a distribution with separate runtime and development packages (e.g. *-dev on Debian).

For what I read so far in comments/issues, seems to effectively affect Ubuntu/derivative distros.

Having a similar problem on Debian Buster.

Interestingly, when I comment out the reset on FIRST_RUN=false in the if/then loop of main, it works.

@linuxclowns Doesnt commenting out FIRST_RUN=false create new sxiv windows?

Since this seems to be an issue on Ubuntu and derivative distros, I think it would be best to have a note in the README stating that if you use Ubuntu or its a distro that is based on Ubuntu, then you have to manually download and compile sxiv.

What are your guys thoughts on this?

@maxdevjs no i do use Debian.

@nilskuehme Well, Ubuntu is based on Debian, so it might be an issue with all Debian based distros

I would recommend to change line 113 to:

    if [ $FIRST_RUN == true || ! -z $(ps -o pid= -p $(cat $PIDFILE)) ]; then

That checks if sxvi is still running and else restarts it. Seems a good idea anyway. Works for me.

Of course it's rather:

if [ $FIRST_RUN == true ] || [ ! -z $(ps -o pid= -p $(cat $PIDFILE)) ]; then

Sorry for the typo.

@SebastianMeisel Hmmm.... not sure if it is working as intended
image

Could you test this? It seems to work, when sxvi is crashing, but I can't test, if it works if sxvi keeps running:

   if [ $FIRST_RUN == true ] ; then
        FIRST_RUN=false

        # 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"
 elif [ -f $PIDFILE ] && ! PID=$(cat $PIDFILE) [ -n "$PID" -a -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

@SebastianMeisel Same issue...
image

And here is the code that I added:
image

Last try:

        # Save the process ID so that we can kill
        # sxiv when the user exits the script
        echo $! >"$PIDFILE"
 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

@SebastianMeisel Yay it works! Looks like your last try was the best try 😊
Could you make a PR for this?

This has been fixed in version 1.0.2, #21