-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.js
More file actions
39 lines (34 loc) · 1.06 KB
/
extension.js
File metadata and controls
39 lines (34 loc) · 1.06 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
const { St, GLib, Clutter } = imports.gi;
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
let clockMenu;
let clockLabel;
let timeoutId;
function updateClock() {
let now = new Date();
let dateString = now.toLocaleDateString('ja-JP', { month: 'numeric', day: 'numeric' });
let timeString = now.toLocaleTimeString('ja-JP', { hour: '2-digit', minute: '2-digit' });
clockLabel.set_text(dateString + ' ' + timeString);
}
function init() {
// 初期化処理(今は特にない)
}
function enable() {
clockMenu = new PanelMenu.Button(0.0, "Custom Clock", false);
clockLabel = new St.Label({
text: '',
y_align: Clutter.ActorAlign.CENTER
});
clockMenu.add_actor(clockLabel);
Main.panel.addToStatusArea('custom-clock', clockMenu, 1, 'right');
updateClock();
timeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, updateClock);
}
function disable() {
if (timeoutId) {
GLib.source_remove(timeoutId);
timeoutId = null;
}
clockMenu.destroy();
clockMenu = null;
}