-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.ts
More file actions
57 lines (46 loc) · 1.39 KB
/
Copy pathextension.ts
File metadata and controls
57 lines (46 loc) · 1.39 KB
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
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js';
import Hakawaka from "./extension/hakawaka.js";
export default class HakaWakaExtension extends Extension {
private gsettings?: Gio.Settings;
private gsettingsId?: number;
private container?: InstanceType<typeof Hakawaka>
private updateId?: number;
enable() {
this.gsettings = this.getSettings();
this.gsettingsId = this.gsettings.connect("changed", this.startTimer.bind(this))
this.container = new Hakawaka(this.gsettings);
this.container.place(this.uuid)
this.startTimer()
}
disable() {
if (this.gsettingsId) {
this.gsettings?.disconnect(this.gsettingsId)
this.gsettingsId = undefined
}
if (this.updateId) {
GLib.source_remove(this.updateId);
this.updateId = undefined;
}
this.container?.destroy()
this.container = undefined;
this.gsettings = undefined;
}
private startTimer() {
if (this.updateId) {
GLib.source_remove(this.updateId);
this.updateId = undefined;
}
this.container?.update();
const interval = this.gsettings?.get_int("refresh-interval") || 10;
this.updateId = GLib.timeout_add_seconds(
GLib.PRIORITY_DEFAULT,
interval * 60,
() => {
this.container?.update()
return GLib.SOURCE_CONTINUE
}
)
}
}