well I noticed xdg-open
command not working as expected for opnening files or urls
and after a deep investigation I found the below
Trace:
bash -x xdg-open "https://suckless.org"
after running the above line I found the code enters an infinite loop of recursion which cause to terminate with seg fault the function with the problem: /usr/bin/xdg-open:819
for d in $dir/*/; do
[ -d "$d" ] && search_desktop_file "$default" "$d" "$target"
done
But why this happens in the first place, well it was fairly simple which I'm going to discuss below
Root Cause:
- xdg-open tries first to get all possible locations for target applications like
- ~/.local/share/applications
- /usr/local/share/applications
- /usr/share/application
- if there's any child dir there it loop throug it recursively
- the problem happens when a directory name has a space
- in my case it was like this
ls -la ~/.local/share/applications//wine//Programs//Rockstar Games/
ls: cannot access '~/.local/share/applications//wine//Programs//Rockstar': No such file or directory Games/: total 12 drwxrwxrwx 3 void void 4096 Feb 26 19:54 . drwx------ 43 void void 4096 May 29 12:32 .. drwxr-xr-x 5 void void 4096 May 24 22:36 epic-games-store this got the tool to look up in a very different files which causes to loop infintly
Fix:
- the easy fix is to change the dir name and remove any space, better if you can keep only desktop files inside the ~/.local/share/applications
Fix: the easy fix is to change the dir name and remove any space, better if you can keep only desktop files inside the ~/.local/share/applications