Can disper fire an event when monitor connected/removed?

Asked by Nikke

Hi!

We're writing a simple GUI for disper in the form of a gnome panel applet and now also an indicator version; when clicked it shows a menu with the current monitor setup (i.e. the menu is built dynamically depending on what monitors are currently attached).
The panel applet works fine, as the applet fires a signal when clicked. We catch that signal, call disper.switcher.get_displays() and build the menu accordingly.

The indicator version poses a problem however. The problem is that the indicator does not fire a signal when clicked -- there is (to my best knowledge) no way to detect when the indicator drop-down menu is to be shown, and hence no "good time" to build the menu. Rather you attach a gtk.Menu object to the indicator and should there at any point be a need to change the menu, you simply edit the menu-object. The problem is that, in order to modify the menu if a monitor is attached or removed, we would need disper to fire an event/signal notifying that a monitor has been attached or removed.

Currently, I have hacked together a simple way to simulate this by polling switcher.get_displays() every 5 seconds (with gobject.timeout_add) and then rebuilding the menu if a change in attached monitors is detected. It works, but there are a couple of problems with this approach however:
- There is of course a lag of up to 5 seconds before the menu is updated
- It's polling... i.e waste of resources
- When the poll is done, there is a small but noticeable system lag when update is done

Is there a better way to accomplish this with disper currently, or any idea how to do it?

Best regards
/N

Question information

Language:
English Edit question
Status:
Open
For:
disper Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

Can you help with this problem?

Provide an answer of your own, or ask Nikke for more information if necessary.

To post a message you must log in.