Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //System Shutdown and Restart Applet by Shelley
- // Edited to use systemd to suspend, restart, hibernate and poweroff by Gabriel (gbc921)
- const Cinnamon = imports.gi.Cinnamon;
- const Applet = imports.ui.applet;
- const Main = imports.ui.main;
- const Lang = imports.lang;
- const St = imports.gi.St;
- const PopupMenu = imports.ui.popupMenu;
- const Util = imports.misc.util;
- const GLib = imports.gi.GLib;
- const ModalDialog = imports.ui.modalDialog;
- function ConfirmDialog(){
- this._init();
- }
- function MyApplet(orientation) {
- this._init(orientation);
- }
- MyApplet.prototype = {
- __proto__: Applet.IconApplet.prototype,
- _init: function(orientation) {
- Applet.IconApplet.prototype._init.call(this, orientation);
- try {
- this.set_applet_icon_symbolic_name("system-shutdown");
- this.set_applet_tooltip(_("Shutdown"));
- this.menuManager = new PopupMenu.PopupMenuManager(this);
- this.menu = new Applet.AppletPopupMenu(this, orientation);
- this.menuManager.addMenu(this.menu);
- this._contentSection = new PopupMenu.PopupMenuSection();
- this.menu.addMenuItem(this._contentSection);
- this.menu.addAction(_("Screen Lock"), function(event) {
- Util.spawnCommandLine("dbus-send --session --type=method_call --print-reply --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock");
- });
- this.menu.addAction(_("Suspend"), function(event) {
- Util.spawnCommandLine("systemctl suspend");
- });
- this.menu.addAction(_("Hibernate"), function(event) {
- Util.spawnCommandLine("systemctl hibernate");
- });
- this.menu.addAction(_("Restart"), function(event) {
- Util.spawnCommandLine("systemctl reboot");
- });
- this.menu.addAction(_("Log Out"), function(event) {
- Util.spawnCommandLine("dbus-send --session --type=method_call --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.Logout uint32:1");
- });
- this.menu.addAction(_("Shutdown"), function(event) {
- Util.spawnCommandLine("systemctl poweroff");
- });
- }
- catch (e) {
- global.logError(e);
- }
- },
- on_applet_clicked: function(event) {
- this.menu.toggle();
- },
- };
- function main(metadata, orientation) {
- let myApplet = new MyApplet(orientation);
- return myApplet;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement