petterreinholdtsen / battery-stats

Log battery charge (battery-stats-collector), show gnuplot graphs (battery-graph)
GNU General Public License v2.0
27 stars 13 forks source link

exit gnuplot after close dialog #33

Open GHolk opened 5 years ago

GHolk commented 5 years ago

--persist option keep graph window live. however, because you remove the temp file, window often crash when zoom or panning.

i suggest that use pause mouse close which make gnuplot wait til window close. then you can remove temperary file safely after gnuplot exit.

this would be a easy patch like this. do you want me to send pull request?

--- /usr/bin/battery-graph  2016-11-17 18:51:44.000000000 +0800
+++ ./battery-graph 2019-01-02 22:10:36.559350289 +0800
@@ -217,10 +217,8 @@
     if $SWITCH_RATE ; then 
        echo ", g(x -($TIME_LAST_DISCHARGE_BEGIN-$adjustment) ) title (B<0?sprintf(\"slope= (%.2f +/- %.2f) %/h\", B*3600, B_err*3600):\"\") lc rgb \"black\" lt 2 "
     fi
+    echo pause mouse close

-)  | gnuplot -persist ${geometry:+-geometry} $geometry ${title:+-title} "${title}" ; rm -f $TMPFILENAME
+)  | gnuplot ${geometry:+-geometry} $geometry ${title:+-title} "${title}"

-
-# TODO Have to decide if we want to clean up or leave the file for us to zoom in/out in the graph
-# For now we will just go the clean way and delete everything again.
 rm -f $TMPFILENAME