Disclaimer: I'm fairly new to Python and Ubuntu. Full code is on https://github.com/bluppfisk/coinprice-indicator/tree/multipletickers
I'm adjusting a cryptocoin price ticker, which uses libappindicator to show up in the taskbar in Ubuntu, to be able to run multiple instances of itself.
However, it looks like the system can't tell the various notification items apart, and tries to overwrite them rather than add another. Error:
libappindicator-WARNING **: Unable to register object on path '/org/ayatana/NotificationItem/Coin_Price_indicator': An object is already exported for the interface org.kde.StatusNotifierItem at /org/ayatana/NotificationItem/Coin_Price_indicator
I thought creating a new instance of the Indicator class (which starts the NotificationItem) should automatically do this. In addition, I multithreaded them and started the main Gtk thread after starting the threads:
for cp_instance in cp_instances:
++counter
settings = cp_instance['exchange'] + ':' + cp_instance['asset_pair'] + ':' + str(cp_instance['refresh'])
indicator = Indicator(config, 'indicator' + str(counter), counter, config, settings)
indicators.append(indicator)
for indicator in indicators:
indicator.start()
indicator.join()
Gtk.main()
Indicator.py
class Indicator(object):
def __init__(self, config, settings=None):
self.config = config
self.settings = Settings(settings)
self.refresh_frequency = self.settings.refresh()
self.active_exchange = self.settings.exchange()
icon = self.config['project_root'] + '/resources/icon_32px.png'
self.indicator = AppIndicator.Indicator.new(self.config['app']['name'], icon,
AppIndicator.IndicatorCategory.APPLICATION_STATUS)
self.indicator.set_status(AppIndicator.IndicatorStatus.ACTIVE)
self.indicator.set_label("syncing", "$888.88")
self.exchanges = None
Problem was with
AppIndicator.Indicator.new()
. Running multiple instances would always receive the same name and therefore take up each other's space. Changing the first argument for every instance run is the solution.