Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

enter image description here

I want to change GUI menu of ubuntu. That is, I want to add a icon at the menu (top of screen), after clicking that a menu will be shown and selecting particular option will run a particular command.

Can some please help me

share|improve this question
do you have the option to alt-right click on the bar? – pfeiffep Apr 6 '13 at 16:23
I am using gnome there is no such option on bar....I have added my desktop image in question – TLE Apr 7 '13 at 7:27
In gnome session fallback I have that option - sorry I can't help – pfeiffep Apr 7 '13 at 10:39
up vote 2 down vote accepted

You can create a simple python applet. Here is a very simple applet I have which I have noted where to put your commands and names for the commands:

#!/usr/bin/env python
import sys
import gtk
import appindicator
import subprocess
import os

repo_name = "Name Of Indicator"

def sh_escape(s):
    return s.replace("\"","\\\"")

class Commands:
    def __init__(self, title="Unknown", command=""):
        self.title = title
        self.command = command

commandArr = [];
commandArr.append(Commands("Command 1 name","command one"))
commandArr.append(Commands("Command 2 name","command two"))

class RemoteApplet:
    def __init__(self):
        self.ind = appindicator.Indicator(repo_name,


    def menu_setup(self): = gtk.Menu()
        self.command_items = []
        cnt = 0
        for x in commandArr:
            self.command_items[-1].connect("activate", self.handleitem, cnt)
            cnt += 1
        self.quit_item = gtk.MenuItem("Quit")
        self.quit_item.connect("activate", self.quit)

    def main(self):
        print "Started!"

    def quit(self, widget):

    def login(self):

    def handleitem(self, widget, index):
        print "Running... " + commandArr[index].command
        proc = subprocess.Popen(commandArr[index].command,stdout=subprocess.PIPE, shell=True)
        (out, err) = proc.communicate()
        os.system("/usr/bin/notify-send \"" + sh_escape(repo_name + " - Output") + "\" \"" + sh_escape(out) + "\"")

if __name__ == "__main__":
    print "Starting..."
    indicator = RemoteApplet()
share|improve this answer
But how can I create icon and by clicking on that I can run my commands. – TLE Apr 7 '13 at 8:30
I would assume you would instead or running the line self.ind.set_label(repo_name) run `self.ind.set_icon('path-to-icon.jpg')' – Benjamin Kaiser Apr 7 '13 at 10:31
This code only works in unity how to make it work in gnome. – TLE Apr 14 '13 at 19:25
There is a bottom bar in Gnome 3 that has your applets. The applet will be there. – Benjamin Kaiser Apr 15 '13 at 0:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.