xlucn / xdg-xmenu

Minimal app menu with xmenu
MIT License
36 stars 4 forks source link

Unable to copy some icons to cache, still used in menu file. #3

Closed myrkvi closed 4 years ago

myrkvi commented 4 years ago

Running the command xdg-xmenu > menu results in some icons not stored in standard(?) paths not being copied to their intended location.

Error saving to file: /home/myrkvi/.cache/xdg-xmenu/icons/opt/intellij-idea-ultimate-edition/bin/idea.png
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/share/pixmaps/jetbrains-toolbox.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/home/myrkvi/.pia_manager/pia_tray_files/img/icon_512x512.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/share/bzflag/bzflag-48x48.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/share/hplip/data/images/128x128/hp_logo.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/share/icons/Humanity/devices/48/printer.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/local/bin/immersed-res/icon.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/opt/goland/bin/goland.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/share/lightworks/Icons/App.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/share/pixmaps/nvidia-settings.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/share/pixmaps/r.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/opt/runescape/share/img/runescape.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/opt/runescape/share/img/runescape.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/opt/runescape/share/img/update-runescape.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/home/myrkvi/.cache/yay/skype-desktop-bin/pkg/skype-desktop-bin/opt/skype_unofficial_client/skype.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/share/racket/slideshow-exe-icon.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/opt/st/stm32cubeide_1.3.0/icon.xpm': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/var/lib/snapd/snap/teams-for-linux/105/meta/gui/icon.png': No such file or directory

I'm assuming this is because the parent directories for the icon files within ~/.cache/xdg-menu/icons do not exist. These paths are still included for the programs, and xmenu then fails to run because it cannot find the images.

xlucn commented 4 years ago

I found where the problem is. For icons that is specified as a file path instead of a name in the .desktop files, I was trying to get their basename through shell string processing:

https://github.com/OliverLew/xdg-xmenu/blob/dc97c66492a640a936dcf11429a03704f7a38a52/xdg-xmenu#L79

The problem is I am only removing everything before the first / by ${1#*/}, thus the full path of the icon is appended to the cache location, so cp fails due to the absence of the nested dirs.

What I need to do is ${1##*/}, even though that is still not equivalent to basename but close enough in most cases.

I pushed a commit to fix this, you can try it and see if works.

Edit: didn't mean to close it by me, I forgot this commit message actually does that :) you can reopen if the problem remains

xlucn commented 4 years ago

I see a potential problem here, there are two icon.png icons for different apps: immersed-res and teams-for-linux. That could result in multiple apps using the same icon. I created a issue for that since I can't decide on a way to work around that for now #4

myrkvi commented 4 years ago

Seems to be resolved!

Teams and some other applications seem to be using the fallback icon. (I'm gonna admit that I don't know what immersed-res is as there does not seem to be a related executable).