-
Notifications
You must be signed in to change notification settings - Fork 2
/
extension.js
29 lines (22 loc) · 1.01 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
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Main = imports.ui.main;
const Lang = imports.lang;
let menu, item, suspendAction, powerOffAction;
function init() {
menu = Main.panel.statusArea['aggregateMenu']._system;
item = menu._actionsItem;
suspendAction = menu._createActionButton('media-playback-pause-symbolic', _("Suspend"));
suspendAction.connect('clicked', Lang.bind(menu, menu._onSuspendClicked));
powerOffAction = menu._createActionButton('system-shutdown-symbolic', _("Power Off"));
powerOffAction.connect('clicked', Lang.bind(menu, menu._onPowerOffClicked));
}
function enable() {
item.actor.remove_actor(menu._altSwitcher.actor);
item.actor.add(suspendAction, { expand: true, x_fill: false });
item.actor.add(powerOffAction, { expand: true, x_fill: false });
}
function disable() {
item.actor.remove_actor(suspendAction);
item.actor.remove_actor(powerOffAction);
item.actor.add(menu._altSwitcher.actor, { expand: true, x_fill: false });
}