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 ].

Standard

My first firefox patch

So excited! – Just submitted my first patch for firefox. It was fairly easy, just had to tweak a few things around. Pumped up neverthless. And now there’s this long wait to get the patch reviewed and possibly get it rewritten too. But anyway, it felt good, and I hope to keep going on!.

   nsCOMPtr<nsIURI> uri(aURI);
 
   nsCString uriSpec;
   uri->GetSpec(uriSpec);
   LOG(("WyciwygChannelParent RecvInit [this=%x uri=%s]\n",
        this, uriSpec.get()));
 
+  if(!mChannel)
+	return SendCancelEarly(rv);
+
   nsCOMPtr<nsIIOService> ios(do_GetIOService(&rv));
   if (NS_FAILED(rv))
     return SendCancelEarly(rv);
 
   nsCOMPtr<nsIChannel> chan;
   rv = NS_NewChannel(getter_AddRefs(chan), uri, ios);
   if (NS_FAILED(rv))
     return SendCancelEarly(rv);
@@ -108,65 +111,76 @@ WyciwygChannelParent::RecvInit(const IPC
 
   return true;
 }
 
 bool
 WyciwygChannelParent::RecvAsyncOpen(const IPC::URI& aOriginal,
                                     const PRUint32& aLoadFlags)
 {
-  nsCOMPtr<nsIURI> original(aOriginal);
+  if(mChannel)
+  {
+  	nsCOMPtr<nsIURI> original(aOriginal);
 
-  LOG(("WyciwygChannelParent RecvAsyncOpen [this=%x]\n", this));
+  	LOG(("WyciwygChannelParent RecvAsyncOpen [this=%x]\n", this));
 
-  nsresult rv;
+  	nsresult rv;
 
-  rv = mChannel->SetOriginalURI(original);
-  if (NS_FAILED(rv))
-    return SendCancelEarly(rv);
+  	rv = mChannel->SetOriginalURI(original);
+  	if (NS_FAILED(rv))
+  	  return SendCancelEarly(rv);
 
-  rv = mChannel->SetLoadFlags(aLoadFlags);
-  if (NS_FAILED(rv))
-    return SendCancelEarly(rv);
+  	rv = mChannel->SetLoadFlags(aLoadFlags);
+  	if (NS_FAILED(rv))
+    	return SendCancelEarly(rv);
 
-  rv = mChannel->AsyncOpen(this, nsnull);
-  if (NS_FAILED(rv))
-    return SendCancelEarly(rv);
+  	rv = mChannel->AsyncOpen(this, nsnull);
+  	if (NS_FAILED(rv))
+    	return SendCancelEarly(rv);
 
-  return true;
+  }
+  return true;  
 }
 
 bool
 WyciwygChannelParent::RecvWriteToCacheEntry(const nsString& data)
 {
-  mChannel->WriteToCacheEntry(data);
+  if(mChannel)
+  	mChannel->WriteToCacheEntry(data);
+  	
   return true;
 }
 
 bool
 WyciwygChannelParent::RecvCloseCacheEntry(const nsresult& reason)
 {
-  mChannel->CloseCacheEntry(reason);
+  if(mChannel)
+  	mChannel->CloseCacheEntry(reason);
+  
   return true;
 }
 
 bool
 WyciwygChannelParent::RecvSetCharsetAndSource(const PRInt32& aCharsetSource,
                                               const nsCString& aCharset)
 {
-  mChannel->SetCharsetAndSource(aCharsetSource, aCharset);
+  if(mChannel)
+    mChannel->SetCharsetAndSource(aCharsetSource, aCharset);
+  
   return true;
 }
 
 bool
 WyciwygChannelParent::RecvSetSecurityInfo(const nsCString& aSecurityInfo)
 {
   nsCOMPtr<nsISupports> securityInfo;
   NS_DeserializeObject(aSecurityInfo, getter_AddRefs(securityInfo));
-  mChannel->SetSecurityInfo(securityInfo);
+  if(mChannel)
+  	mChannel->SetSecurityInfo(securityInfo);
+  
   return true;
 }
 
 bool
 WyciwygChannelParent::RecvCancel(const nsresult& aStatusCode)
 {
   if (mChannel)
     mChannel->Cancel(aStatusCode);

PS: The patch got accepted after a few modifications – so there you go – yet another Mozilla contributer.

Standard