Skip to content

Commit

Permalink
Add a custom _generateFileName function in utilrecorder (EasyScreenCa…
Browse files Browse the repository at this point in the history
…st#188)

This replaces the default gnome shell functionality allowing
more flexibility: E.g. now all the placeholder of GLib.DateTime.format
are possible - with the exception of `%d` and `%t`, which keep their
old behaviour.

Additionally, whitespaces are replaced by underscore.

This make it possible to use now the template
`Screencast_%Y%m%0e_%H%M%S` in order to get a filename like
`Screencast_20171230_091325.webm`.

(Note: `%0e` needs to be used instead of `%d` for compatibility).
  • Loading branch information
adangel committed Nov 29, 2021
1 parent 5de190b commit 2c64aa6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ At least gnome-shell 3.38 is required. This version of EasyScreenCast is not com
**Fixes**

* [#130](https://github.com/EasyScreenCast/EasyScreenCast/issues/130): Argument 'accelerator' but got type 'undefined' when loading the preferences dialog
* [#188](https://github.com/EasyScreenCast/EasyScreenCast/issues/188): Improve filename template for the date and time format
* [#299](https://github.com/EasyScreenCast/EasyScreenCast/issues/299): Review results from extensions.gnome.org

# v1.4.0 (42) (2021-10-22)
Expand Down
10 changes: 10 additions & 0 deletions utilrecorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ var CaptureVideo = GObject.registerClass({
}

Lib.TalkativeLog(`-&-path/file template : ${fileRec}`);
fileRec = this._generateFileName(fileRec);
Lib.TalkativeLog(`-&-path/file final : ${fileRec}`);
if (shellVersion >= 40) {
// prefix with a videoconvert element
// see DEFAULT_PIPELINE in https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/dbusServices/screencast/screencastService.js#L26
Expand Down Expand Up @@ -185,4 +187,12 @@ var CaptureVideo = GObject.registerClass({
return true;
});
}

_generateFileName(template) {
template = template.replaceAll('%d', '%0x').replaceAll('%t', '%0X');
const datetime = GLib.DateTime.new_now_local();
const result = datetime.format(template);
const withoutWhitespace = result.replaceAll(' ', '_');
return withoutWhitespace;
}
});

0 comments on commit 2c64aa6

Please sign in to comment.