forked from se1exin/unix-timestamp-clock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.js
67 lines (62 loc) · 1.8 KB
/
extension.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
60
61
62
63
64
65
66
67
const St = imports.gi.St;
const Main = imports.ui.main;
const GnomeDesktop = imports.gi.GnomeDesktop;
const Lang = imports.lang;
const Shell = imports.gi.Shell;
const Clipboard = St.Clipboard.get_default();
const CLIPBOARD_TYPE = St.ClipboardType.CLIPBOARD;
let text, button, label, btn;
let clock, clock_signal_id;
function init() {
clock = new GnomeDesktop.WallClock();
button = new St.Button({
style_class: 'panel-button',
reactive: true,
can_focus: false,
x_fill: true,
y_fill: false,
track_hover: true
});
label = new St.Label({
style_class: 'unixtime',
text: '',
opacity: 200,
x_expand: true
});
button.set_child(label);
button.connect("clicked", function(){
Clipboard.set_text(CLIPBOARD_TYPE, label.get_text()+"000");
});
button2 = new St.Button({
style_class: 'panel-button',
reactive: true,
can_focus: false,
x_fill: true,
y_fill: false,
track_hover: true
});
label2 = new St.Label({
style_class: 'unixtime',
text: '[email protected]',
opacity: 200,
x_expand: true
});
button2.set_child(label2);
button2.connect("clicked", function(){
Clipboard.set_text(CLIPBOARD_TYPE, label2.get_text());
});
}
function enable() {
update_time();
clock_signal_id = clock.connect('notify::clock', Lang.bind(this, this.update_time));
Main.panel._centerBox.insert_child_at_index(button, 1);
Main.panel._centerBox.insert_child_at_index(button2, 2);
}
function disable() {
Main.panel._centerBox.remove_child(button);
clock.disconnect(clock_signal_id);
}
function update_time() {
var now = new Date();
label.set_text(Math.round(now.getTime() / 1000).toString());
}