gui for the script

Bug #619897 reported by Dennis Schwertel on 2010-08-18
This bug affects 3 people
Affects Status Importance Assigned to Milestone

Bug Description

i wrote a very small gui frontend for disper for my basic needs (about 75 lines of code). it allows switching in the following modes: monitor 1, monitor 2, dual screen, extend monitor. this is based on python and gtk and uses the status icon or the application indicators (found in ubuntu). if you are interested in the application, i could send it over.


Dennis Schwertel (tmassassin) wrote :
description: updated
Nikke (nmellegard) wrote :

Hi kinkerl
There's been a gnome-panel applet around for a while that basically does the same (nice initiative, though).

You can check out the source here:
bzr branch lp:~nmellegard/disper/disper-applet-menu-icons

The above branch contains both disper (in the root folder) and disper-applet (in a subfolder). To install disper-applet, just switch to disper-applet and type 'sudo make install'. Though, disper must obviously also be installed on the system...

The applet was started by a Eugene Arshinov a while back. I've modified it to use menu icons and to build the menu dynamically depending on the current monitor config.

Feel free to hack away on it if you like...


Dennis Schwertel (tmassassin) wrote :

hi nikke

i made a quick hack (about 30 lines) to the gnome panel applet and its an indicator applet now. works fine for me :)

but i did run in some problems with the installer or the debuild to create a debian package. i think the icons for the applet are not installed in either of the processes.

anyway: this is working for me right now. i could send you a patch with the changes. right now it kills the gnome-applet functionality. i can build a "hybrid" that can to both(with a cli parameter or something) or copy some of the code for a new package or just give you what i got now.

it would be great to combine this in a working debian package.


Nikke (nmellegard) wrote :

Post the patch here and I'll have a look at it.


Dennis Schwertel (tmassassin) wrote :

diff is attached.
maybe the icon for the indicator doesnt load (i had to place the icon in /usr/share/icons myself but hey, icons are strange for me anyway). you will see


orGSD (orgsd) wrote :

@kinkerl: Thank you for your contributions! Did you end up creating a debian package for this? I would love to test how well it works under KDE. Right now I am using a Plasma toggle switch to achieve this but it is severely limited in terms of functionality, but as a 5 second solution it is functional.

Dennis Schwertel (tmassassin) wrote :

well a debian package for this does exist. at least the needed files to create one. unfortunately it does not work the way it should. is somebody maintaining this branch?

wvengen (wvengen) wrote :

Hi, thanks for your work on this! For the record, there has been work on a qt-based gui as well at .

If the applet can be called more or less completed, I'd be happy to create a disper branch for this. Great to hear you've done some packaging as well.

Dennis Schwertel (tmassassin) wrote :

hi wvengen
how do you plan to handle these "subprojects"?
- gnome-panel
- application indicator and
- qt frontend

if somebody could fix the installer for the gnome-panel then i could copy this over to a new branch and maintain a shiny new app indicator. or this could stay in one branch and one debian package. this would reduce administration overhead and code maintainance.

wvengen (wvengen) wrote :

Hi kinkerl,
What about using lp:disper/<subproject>/trunk, with <subproject>="trunk" for disper itself? Resulting packages can go in the the official disper ppa at lp:~disper-dev/+archive/ppa.
Great to hear you're willing to maintain the app indicator. I'll try to find some time to have a look at lp:~nmellegard/disper/disper-applet-menu-icons 's installation.

wvengen (wvengen) wrote :

Ok, a package that installs and works properly can be found at lp:~wvengen/+junk/disper-applet-menu-icons . I couldn't get it to propose a merge to your branch though, sorry. Changes:
* Install pixmaps too (and include disper pixmap with disper-applet, I think that's the best right now)
* Use DESTDIR the way it is intended
* Allow change of PREFIX
Looks cool!

Some very small issues I encountered:
- The menu pops up not below the icon but at the mouse position. This is not consistent with other applets.
- You may want to list each author on a new line in the credits dialog.
- The about dialog may benefit from a slightly less technical description, e.g. "On-the-fly display switch utility.\nA simple applet for disper." GtkAboutDialog's website link mechanism could then link to the disper website (unless you really would like to host your own). I could add a section about graphical interfaces to the page. And thanks for mentioning my name but you may safely move me to occupy a place with the other authors, if that suits you :).
- Still doubting which of the disper icons are best for the panel icon :)

wvengen (wvengen) wrote :

Code available, still need to be reviewed, completed and imported into an official disper branch.

Changed in disper:
assignee: nobody → wvengen (wvengen)
importance: Undecided → Wishlist
status: New → In Progress
Dennis Schwertel (tmassassin) wrote :

uh nice, i will take a look at the package this weekend.
is the indicator support merged in it?

wvengen (wvengen) wrote :

Hi Dennis, no it is still in the branch as mentioned in comment #11. If you would like to look at the issues mentioned that would be great. If not, I'll do it some time later. When the applet is ready for a first release, I'd like to put the panel subdirectory in an official branch. Does that sound reasonable?

One thing remains though: in disper trunk there is support for plugins, but these only get called when using the newly introduced Disper object. It does not provide a Displays class but I think it would be useful to integrate that into disper. But I don't necessarily want to wait for that right now; the applet is already very useful.

Dennis Schwertel (tmassassin) wrote :

ok i played a little bit the the package for the applet and it installed fine. just some warnings:
W: disper-applet source: native-package-with-dash-version
W: disper-applet source: debhelper-but-no-misc-depends disper-applet
W: disper-applet source: package-uses-deprecated-debhelper-compat-version 4
W: disper-applet source: build-depends-on-python-dev-with-no-arch-any
W: disper-applet source: out-of-date-standards-version 3.8.0 (current is 3.9.1)
W: disper-applet: new-package-should-close-itp-bug

i just got the indicator back to work with the new package (the patch from #5 works fine). only one problem: the icon for the indicator must be in /usr/share/icons/hicolor/disper.png. one better way would be an svg icon placed in /usr/share/icons/hicolor/scalable/apps/disper.svg

Dennis Schwertel (tmassassin) wrote :

ah i just found the disper.svg... doh... but it still should be in /usr/share/icons/hicolor/scalable/apps/ ;)

wvengen (wvengen) wrote :

Hi Dennis, thanks for the notes! I've fixed them in the repository mentioned in comment #11.
I've been looking for the correct install location of the application icon. How do you know that it should be in hicolor? It should be in the Debian filesystem hierarchy standard but I couldn't find it.

wvengen (wvengen) wrote :

So we have an applet and an indicator. Does it make sense to keep both? If there is no relevant difference to the user, it might make sense to merge them so the user doesn't have make a choice when both are equal.

Dennis Schwertel (tmassassin) wrote :

i am developing a little app myself (persy) and the hicolor theme folder works fine. this is copied this from another project. i dont know if its the best place but its a least a working place :)

hm. if done right, an app indicator will fallback to a status icon if the indicator stuff is not available on the os. this way it will still work on fedora etc. i would just merge them and provide a easy method to autostart the indicator (+ maybe a desktop menu entry?!). the gnome-applet will be there if somebody really needs it but it should not be the default.

Nikke (nmellegard) wrote :

Hi guys

First, sorry for my complete absence (been working on my thesis...). Dennis, are you still working on this?

I have been thinking about this a bit, and was wondering whether it would be possible to use Disper and write a back-end to the existing monitor-management-application in gnome (System->preferences->Monitors). The monitor-manager is quite nice, and it seems (from what I can tell) that Disper pretty much provides all features needed.
I've made a (quite half-assed) effort to try to locate the source code for the application to see if it would be possible to extend it with another back-end, but haven't managed to find which project it's part of...

I know this is going in a quite different direction from disper-applet/indicator, but if it would be possible to hook into the official(?) gnome tool for managing monitors it'd be a better solution, wouldn't it? Does anyone know if this has been looked into before?


Nikke (nmellegard) wrote :

Hi all

I've fixed the issue with the menu popping up at the mouse pointer (attaching the patch).

About your app-indicator patch, the setting of the icon needs to be:

       ind = appindicator.Indicator ("disper",

Second parameter need to be set to the path to the icon (just stating "disper" would refer to a stock icon, which doesn't exist). And also, you had chosen CATEGORY_APPLICATION_STATUS, but I was wondering if CATEGORY_HARDWARE wouldn't make more sense?

Nikke (nmellegard) wrote :

I've made some updates to disper-applet:

- Disper-applet can now run as an indicator (thanks Dennis). Run with param -i or --indicator
- Fixed issue with the menu popping up under cursor (properly this time, I was too quick with the fix in #21)
- Changed the description of applet in about-box (as proposed in #11)
- Each author now appears on a separate line in credits in about-box
- Added Dennis Schwertel as author in credits
- Added the disper-icon in the pixmaps folder
- Added mono themed icons (same as the previous, but desaturated)

The new version is available as rev 75 in


Dennis Schwertel (tmassassin) wrote :

Hi Nikke

i will try this first thing tomorrow! did you include the debian fixes from #11 ?

Nikke (nmellegard) wrote :

Hi Dennis

I have not fixed DESTDIR and PREFIX from #11 at this point. Feel free to, if you know how :)

BTW, are you able to push to the branch?


Dennis Schwertel (tmassassin) wrote :

I dont know. I never done anything more with bazar than a "checkout" but i think you have to grant me some additional rights to push in your branch.

wvengen (wvengen) wrote :

Hi, great to see it's progressing! Regarding DESTDIR/PREFIX, you can look at the changes in my branch at lp:~wvengen/+junk/disper-applet-menu-icons .

Regarding bazaar, the personal bzr branches are only accessible to the owner if I am correct. If you want to make a change, just branch it yourself and upload it to your own personal launchpad bzr branch (bzr push lp:~myself/+junk/mybranch, or look at the page). You should then be able to propose a merge with the original branch (though I had some problems with that; still you can just mention your branch here so Nikke can look at the diffs and integrate those he approves).

Nikke (nmellegard) wrote :


I think I have made applied the debian-related changes from wvengen's branch. Thanks!

And, as proposed in #26, if you check out my branch, make changes and send me the diff:s I'll keep the branch updated!

As of now the applet works fine, but the indicator has a few issues:
- The parameter management is *very* rudimentary. @Dennis, looking at your Persy-code, you seems to know how to do it properly :)

- When starting the disper-applet as indicator, the menu is built once and for all on startup. This means that it won't show changes when a monitor is hooked up or removed. We need a way to detect when the indicator is clicked, and then call the __create_menu (as is done for the applet version in the gtk.Menu callback function __cb_click)

Dennis Schwertel (tmassassin) wrote :

i improved the parameter handling a bit. still not perfect but okay (i guess)

Nikke (nmellegard) wrote :

Looked fine, and works! Patch applied, branch updated (rev 80).


works beautifully, thanks! (rev87)

Will this applet be compatible with the upcoming 11.04's new application-indicator structure?

Yet another indicator, this time using Ubuntu's Unity indicator API. Very basic but works on 11.04 Natty.

import gobject
import gtk
import appindicator
import commands

def single(w):
    commands.getstatusoutput('disper -s')

def extend(w):
    commands.getstatusoutput('disper -e')

def clone(w):
    commands.getstatusoutput('disper -c')

def add_menu_item(name, action):
  menu_item = gtk.MenuItem(name)
  menu_item.connect("activate", action)

if __name__ == "__main__":
  ind = appindicator.Indicator ("disper-indicator",
  ind.set_status (appindicator.STATUS_ACTIVE)

  menu = gtk.Menu()

  add_menu_item('Single', single)
  add_menu_item('Extend', extend)
  add_menu_item('Clone', clone)



Primoz Cankar (primoz.cankar) wrote :

If anyone is iterested I've got a shell script that I use to change display layout with a keyboard shortcut. I use Windows Key + F8 which is the same as my laptopts key to change the displays except that there it uses FN key. Any way this with windows key is much more usefull since i can sue a normal keyboard to change the displays. It changes from single to secondary to primary extend right and secondary extend left:

#! /bin/bash
DISPLAYS=$( disper -l | grep display | cut -f2 -d" " )

 # Get primary and if attached secondary display

 # Get used displays
ALL=$(disper -p | grep metamode)
FIRST=$(echo $ALL | cut -f 1 -d "," | cut -f 2 -d ":")
FIRST=$(echo $FIRST | cut -f 1 -d" ")
SECND=$(echo $ALL | cut -f 2 -d "," | cut -f 1 -d ":")
SECND=$(echo $SECND | cut -f 1 -d" ")

XINERAMA=$(disper -p | grep xinerama | cut -f 2 -d ":")

DSPLY=$(echo $ALL | cut -f 2 -d "," | cut -f 5 -d " ")

if [ $DISPLAY0 ] && [ $DISPLAY1 ]
 if [ "$XINERAMA" == "$DISPLAY0, $DISPLAY1" ] && [ $FIRST == $DISPLAY0 ] && [ $SECND == $DISPLAY1 ]
  disper -s -q > /dev/null
  #echo $XINERAMA
 elif [ "$XINERAMA" == "$DISPLAY1, $DISPLAY0" ] && [ $FIRST == $DISPLAY0 ] && [ $SECND == $DISPLAY1 ]
  disper -q -e -d DFP-0,DFP-1 -t left > /dev/null && disper -e -d DFP-0,DFP-1 -t right > /dev/null
  #echo $XINERAMA
 elif [ $FIRST == $DISPLAY0 ] && [ $SECND != $DISPLAY1 ]
  disper -q -S > /dev/null
  #echo $XINERAMA
 elif [ $FIRST == $DISPLAY1 ] && [ $SECND != $DISPLAY1 ]
  disper -q -d $DISPLAY1,$DISPLAY0 -e -t left > /dev/null
  #echo $XINERAMA
 disper -q -s

Nikke: Any news on this? Is this working on Unity?

Alexander: What should one do with your code? where to put it to get a Unity indicator?

Nikke (nmellegard) wrote :

@Christoph: Yes in fact, I've found a way to get the indicator version to work as I want. I will try to update the makefile and debian stuff over the weekend and push the changes...

So, bottom line: yup, an indicator-version that works under Unity is in the pipeline


Nikke (nmellegard) wrote :

Revision 85 of branch disper-indicator (renamed the disper-applet-menu-icons branch) now supports Unity.

How to install:
1. Install disper 0.2.3 or later
2. Check out the disper-indicator branch
3. Run 'sudo make install'
4. Start 'Disper Indicator'

Help needed:
Anyone who knows how to fix the debian stuff to be able to build a .deb file, please make the necessary changes and send me the diff/instructions and I'll fix the branch and set up a PPA for the indicator.


Nikke (nmellegard) wrote :

Update: I've managed to fix the debian stuff so I now can build the .deb-file!

About the setup a PPA, please test and report any problems!


Nikke (nmellegard) wrote :

Disper-indicator is now available in the PPA:

Although it states natty/i386 it should be compatible with older distributions and with amd64 as well. Again, anyone who knows this debian build stuff better than me, please check out the code and improve it :)


Just installed this. Works as expected (On Natty 64bit) as far as I can see, thanks!
The only strange thing is, that the app indicators etc (top bar, all icons on the right side except BFB) are all duplicated on the second monitor, but that's maybe a unity thing, isn't it?

Nikke (nmellegard) wrote :

@Christoph: glad to hear it works, thanks for the report!
And, yup the indicators thing is Unity-related (or at least, beyond the control of disper-indicator).


@Nikke: Hm, something strange has happened - disper-indicator has stopped working. in fact, entering disper-indicator in the terminal yields "command not found". i checked with indicator-disper, just to be sure, same result.
purge/reinstall hasn't helped.
Should I file an extra bug for that, or do we keep it in this one?

Nikke (nmellegard) wrote :

@Christoph: Keep it in this thread for now, so we don't mess up the bug section for Disper. Perhaps we should move disper-indicator to a separate project, I don't know....

Regarding your problem:
- Did you install from the PPA?
- Did it use to work?
- What happens if you write "python /usr/lib/disper-indicator/" in the terminal?


1) Yes
2) Yes
3) python: can't open file '/usr/lib/disper-indicator/disper-applet': [Errno 2] No such file or directory

ls on /usr/lib/disper-indicator shows disper-applet.pyc displays.pyc

Synaptic shows the package as installed, v 0.2.1-1

Nikke (nmellegard) wrote :

Actually all looks fine...

But, you missed the ".py" at the end of the command, it should be:
python /usr/lib/disper-indicator/

Also, could you post the file:

BTW, do you see Disper Indicator under System Tools section in the application menu?


oh, now i feel stupid. ><
using the command you gave, it works as expected. indicator symbol and all. output:
MyDisplays.getDisplays called v0.0.2
MyDisplays.getDisplays returning 2 detected displays

desktop file attached.

Yes I see it in the applications lense, and can successfully start it from there. just not from the command line. a guess: maybe some symlink to /usr/bin or wherever went missing, so command line doesn't work?

Nikke (nmellegard) wrote :

no worries :)

Actually, there's no script installed to /usr/bin ... Probably should be... I'll update the install package.

To get Disper-Indicator to automatically start on login, you'll need to manually add it to the start-up programs in your session.


yeah, I know about the start-up programs. but there, the command I added was "disper-indicator", and that one is not found. should this be something else?

Nikke (nmellegard) wrote :

If you update to version 0.2.2 you should be able to use the command 'disper-indicator'


debili (karatedebili) wrote :

hello, please after running Disper indicator i still don't see any disper indicator in the top panel, running Natty/Unity 64. perhaps a hint how I could troubleshoot this? disper 0.3.0 installed. thank you

Nikke (nmellegard) wrote :

@debili if you've updated to the latest version of disper-indicator (ver 0.2.2) you should be able to run it from the terminal using the command 'disper-indicator'. Try that and post the output here, and we'll see if there are any clues.

If you're still on previous version, you can try running 'python /usr/lib/disper-indicator/' from the terminal instead.


debili (karatedebili) wrote :

hm it seems i've got ver0.2.2 but i had to run the 'python..' command to get the indicator running/appearing.



what happens if you execute "" in the terminal? Because for me, this works, while "disper-indicator" only does not, like for debili.

Nikke (nmellegard) wrote :

Christoph's on to the problem: '' is the script that starts the indicator while 'disper-indicator' is a link pointing to the script.

It appears the Launchpad's internal build routine doesn't allow the way I wanted to create that link... There probably is a better way... wonder what that might be, though.....

Anyway, I'll make a few changes and disper-indicator v 0.2.3 should be up in a while.

Thanks for enduring my trial-and-error learning of Launchpads build-stuffs.

Nikke (nmellegard) wrote :

BTW, just to be on the safe side:
Uninstall the previous version of disper-indicator (ver. 0.2.2); i.e. don't upgrade, rather remove 0.2.2 and then install 0.2.3


debili (karatedebili) wrote :

I uninstalled 0.2.2, updated, and installed 0.2.3. works like it should now. wow, that was quickly done :) keep up the good work

I just wanted to report, works flawlessly for me too, now!

Nikke (nmellegard) wrote :

Good to know, thanks!


To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers