Quit gnuplot when plot window is closed

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Quit gnuplot when plot window is closed

nastydirk
Hello,

I am using gnuplot to display measurment data directly out of my
self-written console-program. So far this works great but the problem is,
that after gnuplot was called by my program, and the terminal with the
plot is shown (wxt), the user has to type "quit" in console to exit
gnuplot and return to my program. My question now is, if it is possible to
automatically quit gnuplot when the terminal window is closed by the user.

Thx 4 help & GreetZ,
Dirk



------------------------------------------------------------------------------

_______________________________________________
gnuplot-info mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gnuplot-info
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Quit gnuplot when plot window is closed

Hans-Bernhard Bröker-2
[hidden email] wrote:
> I am using gnuplot to display measurment data directly out of my
> self-written console-program. So far this works great but the problem is,
> that after gnuplot was called by my program, and the terminal with the
> plot is shown (wxt), the user has to type "quit" in console to exit
> gnuplot and return to my program. My question now is, if it is possible to
> automatically quit gnuplot when the terminal window is closed by the user.

You appear to be searching for the --persist option.


------------------------------------------------------------------------------

_______________________________________________
gnuplot-info mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gnuplot-info
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Quit gnuplot when plot window is closed

nastydirk
> [hidden email] wrote:
>> I am using gnuplot to display measurment data directly out of my
>> self-written console-program. So far this works great but the problem
>> is,
>> that after gnuplot was called by my program, and the terminal with the
>> plot is shown (wxt), the user has to type "quit" in console to exit
>> gnuplot and return to my program. My question now is, if it is possible
>> to
>> automatically quit gnuplot when the terminal window is closed by the
>> user.
>
> You appear to be searching for the --persist option.
>
>

No, I am already using this param. But it only has the effect that the
plot window doesn't close immediately. But the disadvantage of it is (as
described above) that you have to type "quit" to the console to exit
gnuplot. What I need is that gnuplot closes automatically when the plot
window is closed.

For better understanding I have tried to illustrate what I mean here:
http://img714.imageshack.us/img714/5448/gnuplotdesc.jpg



------------------------------------------------------------------------------

_______________________________________________
gnuplot-info mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gnuplot-info
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Quit gnuplot when plot window is closed

tmacchant
Hello



--- nastydirk wrote:

> > [hidden email] wrote:
> >> I am using gnuplot to display measurment data directly out of my
> >> self-written console-program. So far this works great but the problem
> >> is,
> >> that after gnuplot was called by my program, and the terminal with the
> >> plot is shown (wxt), the user has to type "quit" in console to exit
> >> gnuplot and return to my program. My question now is, if it is possible
> >> to
> >> automatically quit gnuplot when the terminal window is closed by the
> >> user.
> >
> > You appear to be searching for the --persist option.
> >
> >
>
> No, I am already using this param. But it only has the effect that the
> plot window doesn't close immediately. But the disadvantage of it is (as
> described above) that you have to type "quit" to the console to exit
> gnuplot. What I need is that gnuplot closes automatically when the plot
> window is closed.
>
> For better understanding I have tried to illustrate what I mean here:
> http://img714.imageshack.us/img714/5448/gnuplotdesc.jpg
>
For windows binary persist option works a little bit different way from that in unixy case. (I have
tested in the cygwin gnuplot+X11)

For unixy case
gnuplot -persist -e "plot sin(x)"

The gnuplot finished persisting the plot. (However, no key and mouse operations on plot window are
active because the gnuplot interactive session is closed.)

For windows case
gnuplot -persist -e "plot sin(x)"

The gnuplot does not finished with the prompt 'gnuplot>'.

To my knowledge, at this moment, it is not possible to realize what you want to do.

Regards

Tatsuro

--------------------------------------
2010 FIFA World Cup News [Yahoo!Sports/sportsnavi]
http://pr.mail.yahoo.co.jp/southafrica2010/

------------------------------------------------------------------------------

_______________________________________________
gnuplot-info mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gnuplot-info
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Quit gnuplot when plot window is closed

pjhoust
This post has NOT been accepted by the mailing list yet.
GIven: RHEL/CENTOS 6 with utilities xwininfo and xev

The following worked for me to create a window destruction notification function within the script that I used to call gnuplot.  Call the function with the name of your gnuplot graph window (yes, you have to name it and make sure it's unique) and a process ID (usually that of the shell running gnuplot) and background it.  When it detects that the given window has been destroyed, it exits sending a SIGUSR1 signal to whatever PID you gave it.  What you do with the signal is up to you but I just do a mass murder.  It woefully lacks any error handling.


###############################################################################
#
# NAME
#   WinDestroyNotify
#
# SYNOPSIS
#   WinDestroyNotify WIN_NAME PID
#  
# DESCRIPTION
#       Waits for X window given by WIN_NAME to be destroyed then sends
#       SIGUSR1 to process given by PID
#
###############################################################################

WinDestroyNotify() {
        local WIN_NAME=$1
        local NOTIFY_PID=$2
        local FIFO="/tmp/WinDestroyNotify.$$.fifo"
        local winid_regex=".*id: ([^ ]*) .*"

        local WIN_ID=
        local LOOP_PID=
        local XEV_PID=

        [[ "$(xwininfo -name "$WIN_NAME" )" =~ ${winid_regex} ]] &&
                WIN_ID=${BASH_REMATCH[1]}

        mkfifo $FIFO >/dev/null 2>&1

        while read line
        do
                [[ $line =~ Destroy ]] && exit
        done <$FIFO &

        LOOP_PID=$!

        xev -id $WIN_ID > $FIFO &
        XEV_PID=$!

        wait $LOOP_PID
        kill $XEV_PID >/dev/null 2>&1
        rm -f $FIFO >/dev/null 2>&1
        kill -USR1 $NOTIFY_PID >/dev/null 2>&1
}

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Quit gnuplot when plot window is closed

pjhoust
In reply to this post by tmacchant
GIven: RHEL/CENTOS 6 with utilities xwininfo and xev

The following worked for me to create a window destruction notification function within the script that I used to call gnuplot.  Call the function with the name of your gnuplot graph window (yes, you have to name it and make sure it's unique) and a process ID (usually that of the shell running gnuplot) and background it.  When it detects that the given window has been destroyed, it exits sending a SIGUSR1 signal to whatever PID you gave it.  What you do with the signal is up to you but I just do a mass murder.


###############################################################################
#
# NAME
#   WinDestroyNotify
#
# SYNOPSIS
#   WinDestroyNotify WIN_NAME PID
#  
# DESCRIPTION
#       Waits for X window given by WIN_NAME to be destroyed then sends
#       SIGUSR1 to process given by PID
#
###############################################################################

WinDestroyNotify() {
        local WIN_NAME=$1
        local NOTIFY_PID=$2
        local FIFO="/tmp/WinDestroyNotify.$$.fifo"
        local winid_regex=".*id: ([^ ]*) .*"

        local WIN_ID=
        local LOOP_PID=
        local XEV_PID=

        [[ "$(xwininfo -name "$WIN_NAME" )" =~ ${winid_regex} ]] &&
                WIN_ID=${BASH_REMATCH[1]}

        mkfifo $FIFO >/dev/null 2>&1

        while read line
        do
                [[ $line =~ Destroy ]] && exit
        done <$FIFO &

        LOOP_PID=$!

        xev -id $WIN_ID > $FIFO &
        XEV_PID=$!

        wait $LOOP_PID
        kill $XEV_PID >/dev/null 2>&1
        rm -f $FIFO >/dev/null 2>&1
        kill -USR1 $NOTIFY_PID >/dev/null 2>&1
}
Loading...