Skip to content

Instantly share code, notes, and snippets.

@BoQsc
Last active September 30, 2018 11:33
Show Gist options
  • Save BoQsc/f6fc102d1eae191e4f11d595466e14d2 to your computer and use it in GitHub Desktop.
Save BoQsc/f6fc102d1eae191e4f11d595466e14d2 to your computer and use it in GitHub Desktop.
Gnome extension research
//Importing Native Modules
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
//Importing GObject-Introspection namespaces
const St = imports.gi.St;
//Importing Gnome-Shell UI
const Main = imports.ui.main;
class Extension {
constructor() {
this.label = null;
this.button = null;
}
enable() {
this.button = new St.Bin({
style_class: 'panel-button',
reactive: true,
can_focus: true,
x_fill: true,
y_fill: false,
track_hover: true
});
this.icon = new St.Icon({
icon_name: 'system-run-symbolic',
style_class: 'system-status-icon'
});
this.button.set_child(this.icon);
// Use panel from Main namespace to insert button at the beginning of panel's right box.
Main.panel._rightBox.insert_child_at_index(this.button, 0);
}
disable() {
Main.panel._rightBox.remove_child(this.button);
}
};
// Init() function is first function that will be initialized, then enable() and disable() will follow.
function init() {
return new Extension();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment