Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update xdg-mime helper #4333

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions share/functions/__fish_print_xdg_applications_directories.fish
@@ -0,0 +1,10 @@
function __fish_print_xdg_applications_directories --description 'Print directories where desktop files are stored'
set -l search_path ~/.local/share/applications /usr/share/applications
if test -d /usr/local/share/applications
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this directory need an explicit check for existence but not the other two? For example, my ubuntu system has /usr/share/applications but does not have a ~/.local/share/applications directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True this should probably be done for all paths. __fish_print_xdg_mimetypes redirects finds stderr to /dev/null but __fish_print_xdg_mimeapps doesn't. This could course error massages in the output.

set search_path $search_path /usr/local/share/applications
end

for p in $search_path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, the fishy way to do this is printf '%s\n' $search_path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now use the loop to check that the directories exist. So I kept it.

echo $p
end
end
2 changes: 1 addition & 1 deletion share/functions/__fish_print_xdg_mimeapps.fish
@@ -1,4 +1,4 @@
function __fish_print_xdg_mimeapps --description 'Print xdg mime applications'
find ~/.local/share/applications/ /usr/share/applications/ -name \*.desktop \( -type f -or -type l \) -printf '%P\n' | sort -u
find (__fish_print_xdg_applications_directories) -name \*.desktop \( -type f -or -type l \) -printf '%P\n' | sort -u

end
2 changes: 1 addition & 1 deletion share/functions/__fish_print_xdg_mimetypes.fish
@@ -1,3 +1,3 @@
function __fish_print_xdg_mimetypes --description 'Print XDG mime types'
cat ~/.local/share/applications/mimeinfo.cache /usr/share/applications/mimeinfo.cache ^/dev/null | string match -v '[MIME Cache]' | string replace = \t
cat {__fish_print_xdg_applications_directories}/mimeinfo.cache ^/dev/null | string match -v '[MIME Cache]' | string replace = \t
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test this? Because it won't work now 😄 "Braces" (sometimes called "curly brackets") are the curly variant. Parentheses are the round variant. You need the parentheses to indicate a subcommand should be run and its output captured. So you removed the wrong pair of punctuation marks. I'll fix it when I merge it. Just a reminder to always double-check that a seemingly trivial change doesn't introduce a problem.

end