-
-
Notifications
You must be signed in to change notification settings - Fork 385
/
Copy pathrecording.js
59 lines (49 loc) · 1.19 KB
/
recording.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import Service from "resource:///com/github/Aylur/ags/service.js";
import Utils from "resource:///com/github/Aylur/ags/utils.js";
class RecordingService extends Service {
static {
Service.register(
this,
{ "recording-status": ["boolean"] },
{ recording: "boolean" },
);
}
#recording = false;
#checkInterval = null;
constructor() {
super();
this.#initRecordingCheck();
}
#initRecordingCheck() {
if (this.#checkInterval) {
clearInterval(this.#checkInterval);
}
this.#checkInterval = setInterval(() => {
this.#checkRecordingStatus();
}, 2000);
}
#checkRecordingStatus() {
try {
const processCheck = Utils.exec("pgrep -x wf-recorder");
const newStatus = processCheck.length > 0;
if (newStatus !== this.#recording) {
this.#recording = newStatus;
this.changed("recording");
}
} catch {
if (this.#recording) {
this.#recording = false;
this.changed("recording");
}
}
}
get recording() {
return this.#recording;
}
destroy() {
if (this.#checkInterval) {
clearInterval(this.#checkInterval);
}
}
}
export default new RecordingService();