This now runs parse_desktop_file in a protected context so that a single
broken desktop file does not break the whole menubar.
Also, the error message that is produced when a Lua error occurs now
also includes the file name of the .desktop file which we attempted to
parse. This should help quite a lot in debugging.
Related-to: https://github.com/awesomeWM/awesome/issues/1880
Signed-off-by: Uli Schlachter <psychon@znc.in>
The return value for this function is used as an index in a table and
Lua does not like nil as an index.
The function that actually looks for icons, find_icon_theme() already
falls back to "hicolor" if it does not find anything via the current
theme, so fix this issue by just falling back to "hicolor" here as well.
Fixes: https://github.com/awesomeWM/awesome/issues/1819
Signed-off-by: Uli Schlachter <psychon@znc.in>
LGI's async support was trying to yield inside a protected call. Lua 5.1
cannot do that. Work around this by reverting to the behaviour before
commit 50cfa6c: Only call the callback in a protected context.
Fixes: https://github.com/awesomeWM/awesome/issues/1837
Signed-off-by: Uli Schlachter <psychon@znc.in>
The previous commit made this code handle invalid directories correctly.
However, it was still possible that we come across invalid file names
for which :get_path() returns nil and then we assumed this was a file
name.
Fix this by silently ignoring such files.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Before this commit, the code always used GFile instances, then used
get_path() for a recursive call and turned the path into a GFile
instance again. This is not only inefficient, but also causes issues
with directories with invalid utf8, because the get_path function
returns nil in this case.
Fix this by keeping things as a GFile all the time.
Signed-off-by: Uli Schlachter <psychon@znc.in>
The freedesktop specifications let desktop files be stored in
different directories indicated by the environment variables
XDG_DATA_HOME and XDG_DATA_DIRS.
Only use the default value for these variables if the variables are
not defined.
This is important for systmes like NixOS which does not follow the LFS
and installs files differently.
The $XDG_DATA_HOME environment variable may not necessarily end in a
slash, so insert it when generating the list of all menu dirs to make
sure the directory can be found.
This changes a line of code that was added in the previous commit.
Previously, when menubar.cache_entries was set to false,
menubar.refresh() was called twice.
Signed-off-by: Uli Schlachter <psychon@znc.in>
The function seems useless and its documentation is wrong. It does not
return a wibox, but a widget. Also, the widget cannot really be used on
its own since it depends on the size of the wibox.
So menubar.get() and its wrapper through the metatable __call should
just be removed. Until then, the needed initialisation code is moved
around a bit and the function is deprecated.
Signed-off-by: Uli Schlachter <psychon@znc.in>
When menubar.refresh() is called, it tries to update the menubar widget.
The call chain looks like this: menulist_update -> common.list_update ->
get_current_page. get_current_page then tries to query information about
the size of the menubar.
Since there is not much point in this, just skip the whole callback in
this case.
Side note: What is the point of menubar.get()? It seems quite useless to
me.
Signed-off-by: Uli Schlachter <psychon@znc.in>
When awesome calls any Lua code, it does so with a protected call. This
means that any kind of Lua error should (there are exceptions) just
result in an error message being printed and everything continuing as
usual. When LGI calls Lua code, it uses a normal call. This means that
in an asynchronous context, that is, when there is no more call
generated by awesome's C code on the call stack, we must be careful,
since any error results in Awesome's unprotected error handler to be
called which restarts the WM.
menubar.utils.parse_dir() asynchronously parses a directory containing
.desktop files. This means that it is no longer in a protected call
context. Let's assume that the code itself is fine. However, the
callback that the caller provided for handling the results can be quite
arbitrary. Make sure that it is run in a protected context.
Helps-with: https://github.com/awesomeWM/awesome/issues/1173
Signed-off-by: Uli Schlachter <psychon@znc.in>
It does not provide much value. The version number is already known to
ldoc globally in the "description" variable.
Signed-off-by: Uli Schlachter <psychon@znc.in>
When not including standard::type in the query for children of a file then Gio
may not look up this information. This might work on some file systems (e.g.
ext4), but other (apparently XFS) do not provide the needed file type
information (see man readdir on the d_type field). The result was that the
menubar contained no entries because no .desktop files were identified as
regular files and thus read.
Fix this by including standard::type in the queries.
Also, this commit makes the code use some pre-defined string constants from Gio
to make "double sure" that typos are caught.
Thanks to @Jajauma for doing the hard part on debugging this.
Fixes: https://github.com/awesomeWM/awesome/issues/863
Signed-off-by: Uli Schlachter <psychon@znc.in>