From 19894057ec25afeab0d10c5e231548a09ea1739d Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 14 Oct 2026 20:03:28 -0700 Subject: vcr: include some text chunks in the png dest If the caller has some textual information to embed in the PNG metadata, it should be able to embed it. This adds three: timestamp: always populated with the current time name: always populated with --name arg, or empty payload: made available for customized usage payload is aimed at strobe users who have some context associated with the strobe request they'd like to embed in an easily machine-readable location attached to the png file. --- src/vmon.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/vmon.c') diff --git a/src/vmon.c b/src/vmon.c index 8e11dca..b42b5df 100644 --- a/src/vmon.c +++ b/src/vmon.c @@ -808,7 +808,7 @@ static void vmon_resize(vmon_t *vmon, int width, int height) /* this is like vmon_snapshot() except in-place at a fixed name; truncates what's there, no atomicity */ -static int vmon_strobe(vmon_t *vmon) +static int vmon_strobe(vmon_t *vmon, const char *payload) { #ifdef USE_PNG FILE *output; @@ -823,7 +823,7 @@ static int vmon_strobe(vmon_t *vmon) { vcr_dest_t *png_dest; - png_dest = vcr_dest_png_new(vmon->vcr_backend, output); + png_dest = vcr_dest_png_new(vmon->vcr_backend, output, vmon->name, payload); if (!png_dest) { (void) unlink(vmon->strobe_file); (void) fclose(output); @@ -849,7 +849,7 @@ static int vmon_strobe(vmon_t *vmon) } -static int vmon_snapshot(vmon_t *vmon) +static int vmon_snapshot(vmon_t *vmon, const char *payload) { #ifdef USE_PNG time_t now, *t_ptr = &now; @@ -905,7 +905,7 @@ static int vmon_snapshot(vmon_t *vmon) { vcr_dest_t *png_dest; - png_dest = vcr_dest_png_new(vmon->vcr_backend, output); + png_dest = vcr_dest_png_new(vmon->vcr_backend, output, vmon->name, payload); if (!png_dest) { (void) unlink(tmp_path); (void) fclose(output); @@ -1037,7 +1037,7 @@ int main(int argc, const char * const *argv) continue; if (WIFEXITED(status) || WIFSIGNALED(status)) { - if (vmon->snapshot && (r = vmon_snapshot(vmon)) < 0) + if (vmon->snapshot && (r = vmon_snapshot(vmon, NULL)) < 0) VWM_ERROR("error saving snapshot: %s", strerror(-r)); ret = WEXITSTATUS(status); @@ -1056,7 +1056,7 @@ int main(int argc, const char * const *argv) if (got_sigusr2) { int r; - if ((r = vmon_strobe(vmon)) < 0) + if ((r = vmon_strobe(vmon, NULL)) < 0) VWM_ERROR("error saving strobe file: %s", strerror(-r)); got_sigusr2 = 0; @@ -1065,7 +1065,7 @@ int main(int argc, const char * const *argv) if (got_sigusr1 || (vmon->snapshots_interval && !vmon->n_snapshots)) { int r; - if ((r = vmon_snapshot(vmon)) < 0) + if ((r = vmon_snapshot(vmon, NULL)) < 0) VWM_ERROR("error saving snapshot: %s", strerror(-r)); got_sigusr1 = 0; -- cgit v1.2.3