stefano-m / awesome-power_widget

A Power widget for the Awesome Window Manager
GNU General Public License v3.0
26 stars 2 forks source link

Issue caused by multiple GTK versions #6

Open D1CED opened 2 years ago

D1CED commented 2 years ago

Hi, I'm using your widget in my awesomewm configuration but the presence of GTK3 and GTK4 is causing issues with this widget.

In line 23 you are accessing the get_default function of the class IconTheme. This is only available on GTK3 but I assume on my machine the GTK instance on lgi is loaded as GTK4 so this call fails as attempting to call a nil value.

local icon_theme = lgi.Gtk.IconTheme.get_default()

The fix is really simple. You just load a specific version of GTK beforehand by using the require function of lgi.

local Gtk = lgi.require('Gtk', '3.0')
local icon_theme = Gtk.IconTheme.get_default()

The Gtk table can also be used in the next line when accessing the IconLookupFlags attribute.

This is the diff.

23,24c23,25
< local icon_theme = lgi.Gtk.IconTheme.get_default()
< local IconLookupFlags = lgi.Gtk.IconLookupFlags
---
> local Gtk = lgi.require('Gtk', '3.0')
> local icon_theme = Gtk.IconTheme.get_default()
> local IconLookupFlags = Gtk.IconLookupFlags

Please consider including this patch.

Thanks for creating this widget. JMH

stefano-m commented 2 years ago

Hi, thanks for reporting this. I'm going to have a look at it when I have some spare time.