Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fvwm-menu-desktop only produces half the xdg-menu #177

Closed
MasterP-theGu opened this issue Jul 30, 2020 · 14 comments · Fixed by #178 or #180
Closed

fvwm-menu-desktop only produces half the xdg-menu #177

MasterP-theGu opened this issue Jul 30, 2020 · 14 comments · Fixed by #178 or #180
Labels
type:bug Something's broken!
Milestone

Comments

@MasterP-theGu
Copy link

From roughly the penultimate (?) update of master branch on, my XDG-menu is broken. The script only produces up to Graphics, and from Internet onwards, the items remain empty. Here's the end of the output, beginning with the final working entry "Grafik":

DestroyMenu "Grafik"
AddToMenu "Grafik" "Grafik" Title
+ "E-book viewer%/home/peter/.fvwm/icons/24x24-calibre-viewer.png%" Exec exec ebook-viewer --detach 
+ "Flameshot%/home/peter/.fvwm/icons/24x24-flameshot.png%" Exec exec flameshot
+ "GNU Image Manipulation Program%/usr/share/icons/hicolor/24x24/apps/gimp.png%" Exec exec gimp-2.10 
+ "LRF viewer%/home/peter/.fvwm/icons/24x24-calibre-viewer.png%" Exec exec lrfviewer 
+ "LibreOffice Draw%/usr/share/icons/hicolor/24x24/apps/libreoffice-draw.png%" Exec exec libreoffice --draw 
%s icon or default icon not found!
+ "XDvi" Exec exec xdvi 
Traceback (most recent call last):
  File "/usr/local/bin/fvwm-menu-desktop", line 877, in <module>
    main()
  File "/usr/local/bin/fvwm-menu-desktop", line 461, in main
    parsemenus(menulist, desktop, desktop_entries)
  File "/usr/local/bin/fvwm-menu-desktop", line 717, in parsemenus
    parsemenu(xdg.Menu.parse(menulist[0]), top, '', desktop_entries)
  File "/usr/local/bin/fvwm-menu-desktop", line 822, in parsemenu
    parsemenu(entry, '', '', desktop_entries)
  File "/usr/local/bin/fvwm-menu-desktop", line 801, in parsemenu
    printmenu(desktop.getName(), desktop.getIcon(), "Exec exec " + execProgram)
  File "/usr/local/bin/fvwm-menu-desktop", line 706, in printmenu
    iconfile = geticonfile(icon) or getdefaulticonfile(command) or icon
  File "/usr/local/bin/fvwm-menu-desktop", line 693, in geticonfile
    if st.check_size():
  File "/usr/local/bin/fvwm-menu-desktop", line 129, in check_size
    return self._do_check()
  File "/usr/local/bin/fvwm-menu-desktop", line 160, in _do_check
    with PIL.Image.open(self.filename) as f:
  File "/usr/lib/python3.8/site-packages/PIL/Image.py", line 2920, in open
    im = _open_core(fp, filename, prefix)
  File "/usr/lib/python3.8/site-packages/PIL/Image.py", line 2902, in _open_core
    im = factory(fp, filename)
  File "/usr/lib/python3.8/site-packages/PIL/ImageFile.py", line 117, in __init__
    self._open()
  File "/usr/lib/python3.8/site-packages/PIL/XpmImagePlugin.py", line 60, in _open
    raise ValueError("cannot read this XPM file")
ValueError: cannot read this XPM file
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.94. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@issue-label-bot issue-label-bot bot added the type:bug Something's broken! label Jul 30, 2020
@ThomasAdam
Copy link
Member

@mikeandmore -- can you take a look at this? Presumably related to the work you've recently done?

@ThomasAdam ThomasAdam added this to the 1.0 milestone Jul 31, 2020
@mikeandmore
Copy link
Contributor

Sure.

It looks like PIL doens't support this particular xpm. Can you upload this xpm to github so that I can take a look?

I think I should catch the exception when this happens too...

@MasterP-theGu
Copy link
Author

MasterP-theGu commented Aug 3, 2020

Thanks!
I could upload it if there was one. I guess it's xdvi that's causing the trouble as the libreoffice draw icon works fine.

My xdvi is part of texlive-bin, and these are the files that come with it:

texlive-bin /usr/bin/xdvi
texlive-bin /usr/bin/xdvi-xaw
texlive-bin /usr/bin/xdvipdfmx
texlive-bin /usr/share/applications/xdvi.desktop
texlive-bin /usr/share/man/man1/xdvi.1.gz
texlive-bin /usr/share/man/man1/xdvipdfmx.1.gz

xdvi.desktop looks like this:

[Desktop Entry]
Name=XDvi
GenericName=DVI Viewer
Exec=xdvi %f
Type=Application
Terminal=false
Categories=Graphics;Viewer;
Keywords=documents;

In my lunchbreak, I'll try to manipulate the .desktop file so that it includes an Icon and let you know if that works (but that wouldn't solve the original trouble, would it?). :D 4

*** Lunchbreak - Edit ***

Nope, doesn't make a difference. Regardless of the entry "Icon=XYZ" in the .desktop file, the script fails.
When I delete xdvi.desktop from /usr/share/applications, the script fails with the following error message (abridged to focus):

+ "LibreOffice Draw%/usr/share/icons/hicolor/24x24/apps/libreoffice-draw.png%" Exec exec libreoffice --draw 
Traceback (most recent call last):
  File "/usr/local/bin/fvwm-menu-desktop", line 877, in <module>
    main()
  File "/usr/local/bin/fvwm-menu-desktop", line 461, in main
[...]
   self._open()
  File "/usr/lib/python3.8/site-packages/PIL/XpmImagePlugin.py", line 60, in _open
    raise ValueError("cannot read this XPM file")
ValueError: cannot read this XPM file

When I delete libreoffice-draw.desktop, the following appears (again abridged):


+ "LRF viewer%/home/peter/.fvwm/icons/24x24-calibre-viewer.png%" Exec exec lrfviewer 
%s icon or default icon not found!
+ "XDvi" Exec exec xdvi 
Traceback (most recent call last):
  File "/usr/local/bin/fvwm-menu-desktop", line 877, in <module>
    main()
[...]
 File "/usr/lib/python3.8/site-packages/PIL/XpmImagePlugin.py", line 60, in _open
    raise ValueError("cannot read this XPM file")
ValueError: cannot read this XPM file

Am I providing info in the right direction?

@mikeandmore
Copy link
Contributor

Do you happen to have a XDvi.xpm under /usr/share/icons or any of its sub-directories?

I'm sure I can make this error disappear, but I just think it's better to display the icon if we can find one...

@MasterP-theGu
Copy link
Author

Initially, no, the texlive-bin package that's installed doesn't provide an icon at all.
Apart from that, I haven't got any xpm icons in the path you're referring to, they're png, svg.
However, I converted xreader.png into xdvi.xpm to at least have an xdvi.xpm at hand.
Without modifying xdvi.desktop, nothing changes, so I'm not going to re-post the same error-output, hope that's ok.
Modyfying xdvi.desktop to include Icon=xdvi.xpm doesn't change anything, either.
To be on the safe side and to make sure my homemade xpm is alright, I attach it here (github doesn't allow uploading xpms, hence the gz)
xdvi.xpm.gz

@mikeandmore
Copy link
Contributor

I created #178, but it just ignores the broken file.

I suspect XDvi is actually fine, it's another xpm that's corrupted. This PR will at least print out which file is broken. Then we can see what does it take to display that xpm file.

@MasterP-theGu
Copy link
Author

Hi, I am most awfully sorry, but nothing I can see has changed. The same error appears in the same place. :(

If it helps: I've now also tried to remove "xpm" from the fvwm-menu-desktop scriptfile, but to no avail.
Similarly, removing my old ~/fvwm/icons doesn't do the trick, either. I am still stuck somewhere between libreoffice Draw and Xdvi.

@mikeandmore
Copy link
Contributor

Does the following patch work?

From 7fdc505884f59b6f53a59d497f604ecd83959432 Mon Sep 17 00:00:00 2001
From: Mike Qin <[email protected]>
Date: Wed, 5 Aug 2020 17:29:54 -0400
Subject: [PATCH] catch when _do_check() fails

---
 bin/fvwm-menu-desktop.in | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/bin/fvwm-menu-desktop.in b/bin/fvwm-menu-desktop.in
index e6763553..94afe442 100644
--- a/bin/fvwm-menu-desktop.in
+++ b/bin/fvwm-menu-desktop.in
@@ -125,8 +125,12 @@ class BaseIconScaleTool(object):
     def check_size(self):
         if self.filename.endswith('.svg'):
             return False
-        
-        return self._do_check()
+        try:
+            return self._do_check()
+        except:
+            # Always try to convert if check_size() fails.
+            # Worst case convert() would fail and ignore the icon.
+            return False
 
     def convert(self, theme_changed):
         # FVWM knows how to render SVGs
-- 
2.24.1

@mikeandmore
Copy link
Contributor

@MasterP-theGu ping?

@MasterP-theGu
Copy link
Author

@mikeandmore pong.
Sorry, I was very busy and more or less offline for a while, but things should become calmer now in my neck of the woods, so...
As soon as I'm on the machine in question, I'll try out the patch you posted and let you know. Thanks a lot for working on this, and apologies for having been shtum these past few days.

@MasterP-theGu
Copy link
Author

It works perfectly! :D
There are a couple of xpm's that fail converting:

> fvwm-menu-desktop | grep Fail
Fail to convert /usr/share/icons/hicolor/24x24/apps/xdvi.xpm.
Fail to convert /usr/share/pixmaps/xsane.xpm.
%s icon or default icon not found!
%s icon or default icon not found!
Fail to convert /usr/share/pixmaps/audacity.xpm.
Fail to convert /usr/share/pixmaps/gxkb.xpm.
Fail to convert /usr/share/icons/hicolor/24x24/apps/xdvi.xpm.
Fail to convert /usr/share/pixmaps/xsane.xpm.
Fail to convert /usr/share/pixmaps/audacity.xpm.
Fail to convert /usr/share/pixmaps/gxkb.xpm.

They're all original xpm's from /usr/share/pixmaps and the one I created using convert for one of my previous reports in this thread.
Other xpm's from /usr/share/pixmaps work fine and appear in the menu. I attach all the XPMs, maybe you find out what prevents some from working.
Cheers!

MasterPsXPMs.zip

@mikeandmore
Copy link
Contributor

@MasterP-theGu these XPM files are weird. I can only open some of them with GraphicsMagick, and none with PIL/Pillow. I guess I'll just skip these.

@MasterP-theGu
Copy link
Author

@mikeandmore I cannot judge the weirdness of XPM files. :D
But I can add info. All of the original XPMs that I packed are included in the official arch packages for armv7h architecture, hence every Arch user will have the same weird files, at least on this architecture.
Strangely enough, I can open all of them with gm (1.3.35-2), but my pillows (7.2.0-1 as well as 6.2.1-1 w/python2) fail, too, even if I call them directly rather than from what you do in your script.
Maybe this helps, maybe not, so please feel free to disregard.

@ThomasAdam ThomasAdam moved this to Done in FVWM3 Sep 18, 2022
@ThomasAdam ThomasAdam added this to FVWM3 Sep 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something's broken!
Projects
Status: Done
3 participants