Key-mon: Can't create a GtkStyleContext without a display connection

I am trying to run key-mon on OpenSuse tumbleweed but I get this message:

(process:5755): Gtk-CRITICAL **: 11:08:37.710: _gtk_css_lookup_resolve: assertion '(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((provider)); GType __t = ((_gtk_style_provider_private_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))' failed
/usr/lib/python3.11/site-packages/keymon/ Warning: g_object_set_data_full: assertion 'G_IS_OBJECT (object)' failed
  self.window = Gtk.Window()

(process:5755): Gtk-ERROR **: 11:08:37.711: Can't create a GtkStyleContext without a display connection
Trace/breakpoint trap (core dumped)

If anyone had this problem and could resolved it please tell me what can I do to solve this.
key-mon is a software that show the keyboard keys combinations and mouse click on the screen that works on python ( I think the problem is with the PyGObject python pakage.

or if there is any alternative apps to do that on linux.
Thanks in advance

  • where did you install key-mon from as it is in no official repository?

This tool is unmaintained and got archived in upstream google repository. Someone copied the dead code to github but it still seems not alive…

It says that is installed from: obs://

This package is not available for Tumbleweed. Only for Factory and Leap…
Additionally it throws several other python errors…i wouldn’t spend much time with this broken and unmaintained piece of software…

ich@laptop:~/Downloads> key-mon
Traceback (most recent call last):
  File "/usr/bin/key-mon", line 2, in <module>
    import keymon.key_mon as km
  File "/usr/lib/python3.11/site-packages/keymon/", line 30, in <module>
    gi.require_version("Gtk", "3.0")
  File "/usr/lib64/python3.11/site-packages/gi/", line 126, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gtk not available

@jfespinal It works fine here, on Tumbleweed GNOME X11…
Screenshot from 2023-09-17 10-43-28

Maybe missing python-gtk, if your running Wayland, perhaps try X11.

Hmm, just tried on Hyprland/Sway installs and runs (no crashes) but doesn’t work…

I have python-gtk and I am on X11

@jfespinal and you installed the openSUSE Factory version?

I have OpenSuse Tumbleweed installed

@jfespial yes but you did install the factory version not one of the others? What desktop environment are you using?

I have installed from here:

Intel or AMD 64-bit desktops, laptops, and servers (x86_64)

I have kde plasma