[RFC,weston,2/2] screenshooter: Add support to output multiple files

Submitted by Tomohiro Komagata on June 26, 2017, 4:06 p.m.

Details

Message ID ee219400-2580-0938-9a75-b5c82975a94a@gmail.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Wayland

Not browsing as part of any series.

Commit Message

Tomohiro Komagata June 26, 2017, 4:06 p.m.
Signed-off-by: Tomohiro Komagata <tomohiro.komagata.aj@gmail.com>
---
  compositor/weston-screenshooter.c | 13 ++++++++++++-
  1 file changed, 12 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/compositor/weston-screenshooter.c b/compositor/weston-screenshooter.c
index 9999909..f8db546 100644
--- a/compositor/weston-screenshooter.c
+++ b/compositor/weston-screenshooter.c
@@ -32,6 +32,7 @@ 
  #include "weston.h"
  #include "weston-screenshooter-server-protocol.h"
  #include "shared/helpers.h"
+#include "file-util.h"

  struct screenshooter {
  	struct weston_compositor *ec;
@@ -142,7 +143,8 @@  recorder_binding(struct weston_keyboard *keyboard, uint32_t time,
  	struct weston_output *output;
  	struct screenshooter *shooter = data;
  	struct weston_recorder *recorder = shooter->recorder;;
-	static const char filename[] = "capture.wcap";
+	char filename[256], timestr[128];
+	int ret;

  	if (recorder) {
  		weston_recorder_stop(recorder);
@@ -154,6 +156,15 @@  recorder_binding(struct weston_keyboard *keyboard, uint32_t time,
  			output = container_of(ec->output_list.next,
  					      struct weston_output, link);

+		if (current_time_str(timestr, sizeof(timestr),
+				     "%F_%H-%M-%S") < 0)
+			return;
+
+		ret = snprintf(filename, sizeof(filename),
+			       "capture-%s.wcap", timestr);
+		if (ret < 0 || (size_t)ret >= sizeof(filename))
+			return;
+
  		shooter->recorder = weston_recorder_start(output, filename);
  	}
  }