Ubuntu – Is it possible to alter and update the status icon of a running indicator applet


I'm trying to create a simple application indicator that mimics the CPU load applet for the gnome-panel.

I currently do this by updating (overwriting) the status icon of the indicator with the new CPU load information and re-set the status icon to the same icon on every update (I know this is stupid, but I don't know if it's currently possible to solve otherwise).

Unfortunately this doesn't work and I always see the "first" icon state, eg.

The indicator icon doesn't update, while the icon's content does.

I also tried to temporarily set the status icon to something else first, eg.


but that didn't work either.

Any ideas?


It is indeed possible to do what I wanted using a hack to cause the indicator to repaint its icon (thanks to Jorge Castro and Ted Gould):


The attention state icon should be the same as the active state icon, else there would be some flicker.

Best Answer

This is indeed not the intended behaviour of Application Indicators: they're meant to have one or two icons and not something that you could almost put in a widget.

There seems to be something wrong in the caching of the icon, as it should update a changed icon, though.

Anyway, you probably want to use something like 'libindicator' to create your own, custom indicator. The collection of application indicators on your panel is drawn by one indicator. You have a lot more functions at your disposal when writing a custom indicator, than when using the limited API of Application Indicators, which was limited deliberately to make sure we don't get a mess.

Also make sure to look at the package 'libindicator-tools', which contains some handy utilities for testing indicators.