Biont/sway-launcher-desktop

No desktop entries: bad array subscript

jlkDE opened this issue · 14 comments

jlkDE commented

Somehow I am missing desktop entries on Ubuntu 20.04, and therefore the script fails because of an empty PROVIDERS array:

sway-launcher-desktop provide
sway-launcher-desktop: line 81: PROVIDERS: bad array subscript

Can you tell me how I can debug the missing entries?

Biont commented

Hello!

You need to pass the name of the provider, in your case:

sway-launcher-desktop provide desktop

I should probably add input validation there

jlkDE commented

Hi,

thank you for your fast support! While this fixes the error, there are still no entries provided unfortunately. All entries provided are commands or Snaps but no regular desktop ones. Rofi for example works as expected.

Biont commented

Could you post the folder(s) where your desktop files are located? I was hoping to satisfy the XDG spec in this function but maybe it's not picking up something important?

jlkDE commented

Per default, /usr/share/applications and its subdirs as expected contain most packaged desktop files and ~/.local/share/applications provides user-defined ones.

If I run this function alone, it returns some paths, but maybe the globbing does not work or the double slash in /usr/share**//**applications causes the issue:

/home/jkiok/.local/share/applications/**/*.desktop /usr/local/share//applications/**/*.desktop /usr/share//applications/screensavers/abstractile.desktop /usr/share//applications/screensavers/binaryring.desktop /usr/share//applications/screensavers/cwaves.desktop /usr/share//applications/screensavers/deco.desktop /usr/share//applications/screensavers/distort.desktop /usr/share//applications/screensavers/fiberlamp.desktop /usr/share//applications/screensavers/fuzzyflakes.desktop /usr/share//applications/screensavers/galaxy.desktop /usr/share//applications/screensavers/hexadrop.desktop /usr/share//applications/screensavers/m6502.desktop /usr/share//applications/screensavers/metaballs.desktop /usr/share//applications/screensavers/penrose.desktop /usr/share//applications/screensavers/ripples.desktop /usr/share//applications/screensavers/shadebobs.desktop /usr/share//applications/screensavers/slidescreen.desktop /usr/share//applications/screensavers/swirl.desktop /usr/share//applications/screensavers/tessellimage.desktop /usr/share//applications/screensavers/xlyap.desktop /var/lib/snapd/desktop/applications/**/*.desktop
Biont commented

Is echo $XDG_DATA_DIRS returning something on your system? One explanation would be that it is is set and that the paths in there contain trailing slashes

jlkDE commented

I thought about that too, but looks ok to me: `/usr/share/sway:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop

Ok, nvm, there seem to be slashes and I overlooked them. Only resetting XDG_DATA_DIRS does not seem to be enough, but I will investigate further from this point on.

Biont commented

But it's right there: /usr/local/share/ and /usr/share/

Related?

Hm..but when I use that on my machine like XDG_DATA_DIRS=/usr/share/sway:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop sway-launcher-desktop list-entries it works without problems.

Does removing the slashes fix the issue for you?

EDIT: Missed your edit, sorry^^

Biont commented

Just to be sure: Are you on bash 4.0+ ?
Maybe this is just missing globstar support

jlkDE commented

Well... The bug indeed seems to be related. Aditionally, globstar is disabled per default on Ubuntu.

I now manually export XDG_DATA_DIRS and I enabled the globstar option, but it is still not working...
At least this loop now expands to all desktop-files, but somehow they are still not present.

jlkDE commented

I really want to thank you for your kind support so thar even though my problems persists!

Biont commented

I enabled the globstar option, but it is still not working...

The script takes care of that itself, so this would have only made sense if globstar is not supported at all.

Does it help if you change L99 to this?

DIRS[$i]="${DIRS[i]%/}/applications/**/*.desktop"

This removes a single trailing slash from each DIR if present. As I said this works without issue on my machine but who knows

jlkDE commented

Unfortunately does not change anything.

The launcher was not displaying any .desktop entries for me on Ubuntu 20.04. It turned out that the standard awk does not contain some features which the launcher uses. sudo apt install gawk resolved the problem for me.

jlkDE commented

You are right, after installing GNU awk desktop entries are shown! Thanks a lot 😁