I am working on a script that would display arbitrary system information on screen. For that purpose I've been trying to use pyosd module.

Consider the following 3 lines:

import pyosd
p = pyosd.osd()

This works alright with python 2.7 interpreter, however , fails when run from a script - no exception is thrown , but nothing is displayed either. How can I troubleshoot this ?

I am open to alternative suggestions, but pynotify also doesn't work for me, as the notifications it raises cannot be placed into arbitrary position of the screen. Note also, that gnome-osd-client is also a useful tool, but i need a standalone script rather than using external application. The script would be aimed at other users, and i don't want them to download extra packages they won't need

  • Serg, Does setting os.environ['DISPLAY'] and os.environ['XAUTHORITY'] work? – heemayl May 8 '16 at 6:34
  • @heemayl it does not. I've also tried settings those values from within the script - didn't help – Sergiy Kolodyazhnyy May 8 '16 at 6:37
  • I can't even get this example to run in 16.04 with python-pyosd installed. The second line gives me the error "pyosd.error: Requested font not found". – Nathan Osman May 8 '16 at 6:54
  • @NathanOsman changing font might help ,but on 14.04 it works alright – Sergiy Kolodyazhnyy May 8 '16 at 7:03
  • the odd thing is that the script runs, without errors. but nothing is displayed – Sergiy Kolodyazhnyy May 8 '16 at 7:14

As stated in http://ichi2.net/pyosd/


Why can I display text interactively, but not in a script?

Text is displayed in a different thread, so you need to keep the program running long enough to see the text. Usually this means adding the following function call at the end of your program:


Thus , the solution was to do this:

#!/usr/bin/env python
import pyosd
p = pyosd.osd( )


The 16.04 LTS appears to have removed many of the fonts used in previous versions. After installing the x11 fonts with sudo apt-get install xfonts-75dpi and reboot, the code works with the default font which is specified in pydoc pyosd:

default_font = '-*-helvetica-medium-r-normal-*-*-360-*-*-p-*-*-*'

enter image description here

  • And so it does. Nice! – Jacob Vlijm May 8 '16 at 10:09
  • It seems you can set the font, though the format is not really clear. I managed to mess with the color though: http://svn.pykota.com/pykota/trunk/bin/pykosd – Jacob Vlijm May 8 '16 at 10:23
  • 1
    @JacobVlijm yes you can set the font , it is supposed to be in X logical font description (XLFD) style. There's also fonts.alias files in various folders on the system, where you can find some of the examples of it. I've been trying to find a suitable one for the past hour or two, but so far only the default works after installing the package i mentioned. As fro 14.04 , well, i managed to find 3 fonts that work, but they fail in 16.04 – Sergiy Kolodyazhnyy May 8 '16 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.