Replace Log off with Power Off button – Gnome 3

I’m just annoyed at having to press the alt button everytime I have to shutdown [ thanks to gnome 3 ] – I’m a laptop user as well. Anyway, here’s a hacky way of getting Log off replaced by Power off.

You could just install the following package for fedora.

[root@xhost ui]# yum install gnome-shell-extensions-alternative-status-menu.noarch

Restart gnome-shell and you should have the power off button.

Otherwise, you can edit the UI js files as described below.

Note :The following involves editing a bit of javascript – make sure you make backups before you do this

Open the js file using your favourite text editor [while having root privileges ].

[root@xhost ui]# vim /usr/share/gnome-shell/js/ui/statusMenu.js

Now, find the area that says

        // If we can't suspend show Power Off... instead
        // and disable the alt key
        if (!this._haveSuspend) {
            this._suspendOrPowerOffItem.updateText(_("Power Off..."), null);
        } else {
            this._suspendOrPowerOffItem.updateText(_("Suspend"), _("Power Off..."));
        }
    },

Swap the text Suspend and Power Off. The resulting code looks like this

            this._suspendOrPowerOffItem.updateText(_("Power Off..."), _("Suspend"));

Actually, you can replace Power off… and Suspend by whatever you’d like to, as long as you know what it does. For example, I can name them as Potato and Tomato, and that would be displayed in screen.

There’s one more part to be changed. Find the part which says

    _onSuspendOrPowerOffActivate: function() {
        Main.overview.hide();

        if (this._haveSuspend &&
            this._suspendOrPowerOffItem.state == PopupMenu.PopupAlternatingMenuItemState.DEFAULT) {
            this._screenSaverProxy.LockRemote(Lang.bind(this, function() {
            this._upClient.suspend_sync(null);
    }));
        } else {

            this._session.ShutdownRemote();
        }
    },

Change the == to !=

Your resulting code should be something like

this._suspendOrPowerOffItem.state != PopupMenu.PopupAlternatingMenuItemState.DEFAULT) {

That’s it, now save the file and restart gnome shell by Alt+F2, and hitting r.

Surprise surprise, you should be finding Power Off… as your default [ Or Tomato, however you have named it ].

Advertisements
Standard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s