Biont / sway-launcher-desktop

TUI Application launcher with Desktop Entry support. Made for SwayWM, but runs anywhere
GNU General Public License v3.0
607 stars 28 forks source link

No desktop entries: bad array subscript #29

Closed jlkDE closed 2 years ago

jlkDE commented 3 years ago

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 3 years ago

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 3 years ago

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 3 years ago

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 3 years ago

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 3 years ago

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 3 years ago

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 3 years ago

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 3 years ago

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

jlkDE commented 3 years ago

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 3 years ago

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

Biont commented 3 years ago

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 3 years ago

Unfortunately does not change anything.

dave-pollock commented 2 years ago

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 2 years ago

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