Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions appindicator-broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ def _menu_clear(self, indicator, args):
indicator.set_menu(menu)

def _menu_add(self, indicator, args):
cmd, _, label = args.partition(' ')
cmd_with_args_str, label = args.split('#')
cmd_with_args_list = cmd_with_args_str.split()
cmd = cmd_with_args_list[0]
args = cmd_with_args_list[1:]
menuitem = Gtk.MenuItem.new_with_label(label)
menuitem.connect('activate', lambda item : self._execute(cmd))
menuitem.connect('activate', lambda item : self._execute(cmd, args))
indicator.get_menu().append(menuitem)

def _destroy(self, indicator, args):
Expand All @@ -99,7 +102,7 @@ def _destroy(self, indicator, args):
#
del self._indicators[indicator.get_id()]

def _execute(self, command):
def _execute(self, command, arguments):
# We double fork to reparent the child process to pid 1

pid = os.fork()
Expand All @@ -114,8 +117,9 @@ def _execute(self, command):

# child process
try:
argv = [command] + arguments
c_pid = os.posix_spawnp(
command, (command,), os.environ,
command, argv, os.environ,
# Not supported on my Python version so can't test.
#
# The named pipe uses O_CLOEXEC but not sure if
Expand Down