How to get icon from windowid

I want to get icon name from window id (the output of wmctrl -l).

I can get which windows are associated with an app using DevDocs

Now the issue is when I run:

#! /usr/bin/python3

from gi.repository import Gio

apps = Gio.AppInfo.get_all()
icon = apps[0].get_icon()
print (icon)

It says <Gio.ThemedIcon object at 0x7f83637f3080 (GThemedIcon at @x7f835400ba30) >

I checked DevDocs :

Gio.Icon does not provide the actual pixmap for the icon as this is out
of GIO’s scope, however implementations of Gio.Icon may contain the name
of an icon (see Gio.ThemedIcon), or the path to an icon (see Gio.LoadableIcon).

I did not find any example on how to use ThemedIcon.

How can I get the actual icon name (The value that is shown in the .desktop file’s Icon=).

icon = apps[0].get_icon().to_string() solved my problem.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.