Skip to content

fix: follow symlinks when grepping for desktop entries#35

Open
cluther wants to merge 1 commit into
Strobotti:mainfrom
cluther:grep-symlinks
Open

fix: follow symlinks when grepping for desktop entries#35
cluther wants to merge 1 commit into
Strobotti:mainfrom
cluther:grep-symlinks

Conversation

@cluther
Copy link
Copy Markdown

@cluther cluther commented Feb 5, 2025

Thank you for writing linkquisition. It's such a great default browser
replacement for those of us that like to use different browsers and profiles
for different purposes. It does just what I need, and no more. I hope you find
this pull request acceptable. It's a small thing, but needed for those who have
symlinks within their $XDG_DATA_DIRS paths. I don't know how common that is,
but it at least affects people installing browsers with Nix home-manager.


When running browsers installed via the Nix home-manager, the browser
.desktop files will be found within ~/.nix-profile/share/applications/
and ~/.nix-profile/share will be in $XDG_DATA_DIRS. The
~/.nix-profile/share directory is a symlink, and grep -r will follow
that successfully, but then the applications/firefox.desktop within
will also be a symlink. A grep -r won't follow that, so we have to use
grep -R to follow all symlinks to actually find the desktop entries.

For example, without this fix, I see the following when running
linkquisition https://google.com.

failed to call grep for determining a .desktop entry for firefox -P Personal --class=firefox-personal %U: exit status 1
failed to call grep for determining a .desktop entry for google-chrome-stable --user-data-dir="/home/cluther/.config/google-chrome-personal" %U: exit status 1

With this change, linkquisition is able to auto-detect all of the
browser entries I have, and launch into them without error.

When running browsers installed via the Nix home-manager, the browser
.desktop files will be found within `~/.nix-profile/share/applications/`
and `~/.nix-profile/share` will be in `$XDG_DATA_DIRS`. The
`~/.nix-profile/share` directory is a symlink, and `grep -r` will follow
that successfully, but then the `applications/firefox.desktop` within
will also be a symlink. A `grep -r` won't follow that, so we have to use
`grep -R` to follow all symlinks to actually find the desktop entries.

For example, without this fix, I see the following when running
`linkquisition https://google.com`.

    failed to call grep for determining a .desktop entry for firefox -P Personal --class=firefox-personal %U: exit status 1
    failed to call grep for determining a .desktop entry for google-chrome-stable --user-data-dir="/home/cluther/.config/google-chrome-personal" %U: exit status 1

With this change, linkquisition is able to auto-detect all of the
browser entries I have, and launch into them without error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant