Ubuntu: How can I hide Empathy's mail indicator icon?



Question:

Since I have configured Empathy, I have a new icon shown in the indicator icon bar. This icon remains visible even if I close Empathy.

How can I have this icon disappear when not using Empathy?

enter image description here


Solution:1

Inspired by cl-netbox' answer, you can automatically remove the icon after empathy closes. This can be done by running (starting) empathy through a wrapper script. As far as I can see, this has no downside. The only possible downside would be that the right- click option to open with does not work, but that does not apply to empathy.

The wrapper would only run during, and only as long as, empathy is running, waiting for it to close, so the solution is very specific.

What it does

  • When empathy is run (through the wrapper), a small script is started, doing two things:

    • look (check) for the empathy indicator to be visible, by the command:

      gsettings get com.canonical.indicator.messages applications  

      This will return a list of current indicators. If the empathy indicator is not included, the script adds it to the list and sets the altered list by the command:

      gsettings set com.canonical.indicator.messages applications <newlist>  
    • Then the script looks for the existence of an empathy window
      If no empathy window exists any more, the script fetches the list of indicators again and removes the indicator in the same way.

  • Then the wrapper- script terminates itself, and your icon is removed from the panel.

The wrapper

#!/usr/bin/env python3  import subprocess  import time    key = "com.canonical.indicator.messages"    def hide_icon(icon, mode):      # function to remove the targeted icon from the list      current = eval(subprocess.check_output([          "gsettings", "get", key, "applications"          ]).decode("utf-8").strip())      if mode == "h":          try:              current.remove(icon)          except ValueError:              pass      elif mode == "s":          if not icon in current:              current.append(icon)      subprocess.call([          "gsettings", "set", key, "applications", str(current)          ])    # run empathy  subprocess.Popen(["empathy"])  # make sure the icon shows  hide_icon('empathy.desktop', "s")    while True:      time.sleep(3)      try:          # get the pid of empathy          pid = subprocess.check_output(["pgrep", "empathy"]).decode("utf-8").strip()      except subprocess.CalledProcessError:          break      else:          try:              # see if the pid of empathy is still in the window list...              wlist = subprocess.check_output(["wmctrl", "-lp"]).decode("utf-8")              # ...if not, remove the icon from the list and break              if not pid in wlist:                  hide_icon('empathy.desktop', "h")                  break          except subprocess.CalledProcessError:              pass  

How to set up

  • Copy the script into an empty file, save it as no_indicator.py

  • Test-run the script with the command:

    python3 /path/to/no_indicator.py  

    The icon should disappear if you close empathy. If all works fine:

  • Copy the global empathy.desktop file to ~/.local/share/applications:

    cp /usr/share/applications/empathy.desktop ~/.local/share/applications  
  • Open the locally copied file with gedit:

    gedit ~/.local/share/applications/empathy.desktop  

    replace the line:

    Exec=empathy  

    by:

    Exec=python3 /path/to/no_indicator.py  
  • just before (above) the line, starting with Actions=, insert the line:

    StartupWMClass=empathy  

    This is to prevent an extra icon in the Launcher when you run empathy

  • Log out and back in


Solution:2

Install the dconf-editor tool ... open a terminal and execute:

sudo apt-get install dconf-editor    

Open dconf Editor, navigate to com â†' canonical â†' indicator â†' messages.

enter image description here

Remove 'empathy.desktop' in the right pane, log out and back in.

enter image description here

Now the Empathy icon doesn't appear in the indicator bar any more.


Note:

The next time you open Empathy, the icon will reappear and you have to repeat the procedure.
When you want to permanently remove the icon, you have to execute the following command:

sudo apt-get remove indicator-messages    

The downside is, that the Thunderbird icon will also be removed - so the decision is up to you ...


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »